wissel.net

Usability - Productivity - Business - The web - Singapore & Twins

Keeping up with all the GIT


Unless you stuck in the last century, you might have noticed, that the gold standard for version control is GIT. Atlassian likes it, IBM DevOps supports it and of course the Linux Kernel is build with it.
The prime destination for opensource projects is GitHub, with BitBucket coming in strong too. Getting the code of a project you work with (and I bet you do - jquery anyone) is just a git clone away. Of course that opens the challenge to keep up with all the changes and updates. While in the projects you work on, a branch, pull and push is daily work - using the command line or a nice UI. For that "keep an eye one" projects this gets tedious quite fast.
I'm using a little script (you even could cron it or attach it to a successful network connection) to keep all my "read-only" repositories up-to-date. You need to change the basedir= to match your path. Enjoy
#!/bin/sh
# Helper script to keep all the things I pulled from GITHUB updated
# most of them are in ~/github, but some are somewhere else

# Pulls a repository from GIT origin or Mercurial
syncrep() {
	echo "Processing $f file..."
	cd $1
	isHG=`find -maxdepth 1 -type d -name ".hg"`
	if [ -n "$isHG"]
	then
		git pull origin master &
	else
		echo "$f is a Mercurial directory"
		hg pull
	fi
}

basedir=/home/yourusername

# Part 1: all in ~/github
notify-send -t 20000 -u low -i gtk-dialog-info "Starting GIT threaded update"
FILES=$basedir/github/*
for f in $FILES
do
	syncrep $f
done

# Part 2: all in ~/company
notify-send -t 20000 -u low -i gtk-dialog-info "Starting COMPANY threaded update"
FILES=$basedir/company/*
for f in $FILES
do
	syncrep $f
done

cd ~
notify-send -t 20000 -u low -i gtk-dialog-info "All GIT pull requests are on their way!"

# Wait for the result
stillrunning=0
while [ "$stillrunning" -eq "0" ]
 do  
	sleep 60
	pgrep git- > /dev/null
	stillrunning=$?
 done
notify-send -t 20000 -u low -i gtk-dialog-info "GIT pull updates completed"

A little caveat: when you actively work on a repository you might not want the combination origin - master, so be aware: as usual YMMV

Posted by on 25 September 2014 | Comments (0) | categories: Software

Comments

  1. No comments yet, be the first to comment