Category ‘Linux’
whatthecommit.com git hook
I currently use Git for most of my version control needs. I'm keeping all of my hand-ins for university under version control to be able to sync them between university and my laptop easily and to make it easy for others to contribute (and sometimes they actually do!). But those of you using version control systems know what the biggest problem with version control is: Thinking of a commit message. Wait no moar! The ultimate solution is here!
whatthecommit.com is a website that provides you with a fresh commit message every time you load it. So all you have to do, is copy and paste the line into your commit window. Still too much work? That's why git comes with hook scripts. Paste the following code in .git/hooks/prepare-commit-msg in your working copy and make the file executable and you'll be provided with a wonderful commit message every time you type git commit automatically!
#!/bin/sh # # A hook script to prepare the commit log message. # Called by "git commit" with the name of the file that has the # commit message, followed by the description of the commit # message's source. The hook's purpose is to edit the commit # message file. If the hook fails with a non-zero status, # the commit is aborted. case "$2,$3" in ,|template,) line=$( wget http://whatthecommit.com/ -O - 2>/dev/null | grep -o '<p>.*$' | sed 's/<[^>]*>//g' ) file=$( sed '1d' "${1}" ) echo "${line}" > "${1}" echo "${file}" >> "${1}" ;; *) ;; esac
Subversion Property Copy
Although there is a couple of Subversion GUIs for Macs, I usually use the CLI. I manage all source code I write during my studies using Subversion and usually add revision number and date of last checkin to the file using the svn:keywords-Property. However, I always forget the set of keywords I usually add: Author Date Id Revision URL. Unfortunately, there is no way to copy a property from one file to another in the standard subversion binary. There is, however, a little shortcut:
svn propset $propertyName "`svn propget $propertyName $fromFileName`" $toFileName
Typing this monster isn’t any userfriendly at all, though – a little
.bashrc magic does the trick:
# add svn propcopy function svn() { case "$1" in pc|propcopy) propName=$2 fromFile=$3 shift 3 `which svn` propset $propName "`\`which svn\` propget $propName $fromFile`" $@ ;; *) `which svn` $@ ;; esac }
Update: Thanks to Raim for the wildcard support. Using subversion auto-props is an option for files, but unfortunately, auto-props don’t work on directories yet.
A Friday 13th story
Are you superstitious? Do you believe in Murphy’s law? I usually don’t believe in such things, but sometimes you start to have doubts…
This site is served by my own virtual server hosted by Carrot Servers in Austria. The hardware nodes running their servers are housed in one of Germany’s largest hosting company’s datacenters. However, three of their datacenters recently suffered from a power loss because of a defunct uninterruptible power source and a series of other unfortunate problems – a little over 12,000 servers were without power for a few hours.
However, it seems my vServer’s hardware node was damaged by the power loss; one of the hard disk drives in the RAID array was replaced after the outage. Yesterday, the worst-case scenario came true: besides the hard disks, apparently the motherboard was also damaged causing the RAID controller to slowly corrupt the data on the drives. On Friday, 13th, my provider informed me data had been lost and the server will be swapped with a new machine.
Luckily, I did remember creating backup – and it happened to be a recent one (namely from Thursday, 12th). But as Murphy’s law states, things never work the way you expect them to work. In this case that meant that permissions were incorrect on the backup although I used rsync with the appropriate preserve-permissions option. I’ve thus been busy reinstalling the software, uploading the files and databases and fixing their permission. As of now, all data has been successfully restored (blessing in disguise) and I’m supervising the server’s functions.