An update (perl) script for updating github repositories.
One of the challenges of the drools/jbpm/kie project is that there are lots or repositories — even more so with the 6.x branch. Of course, there are the core repositories (drools, jbpm), the shared API repositories, the integration repositories and then once you start looking at the appliations, most of which based on the new UberFire framework, the list just keeps on growing.
There’s also the fact that I regularly dive into the code of say, Hibernate, Hornetq, RestEasy or Wildfly. Of course, then there are git repositories with examples, Arquillian container repositories..
You get the point.
What I wanted to share with you is a script that I use to regularly update all of these repositories. You can find it here, where I’ve pasted it into a github gist.
First off, the script assumes that it’s in the parent directory of your repository. That is to say that if all of your github repositories are in /home/me/workspace, then the script assumes that it’s been started there.
This script does the following for every repository that you give it:
- Changes directory into the repository.
git remote update
- Checks to see that the current (git) branch is master.
- Checks to see if there are any changes to the repository (any file changes that are unstaged, in the index or otherwise not committed).
git merge --ff origin/master
- Prints the output of
The list of repositories can be found at the end of the script, underneath the __DATA__ tag in the perl script. You can also add comments in the list.
Of course, you can restart the script halfway if you want to by calling ./update.pl -f <repo> (which restarts “from” that repo) or ./update.pl -a <repo> (which restarts “after” that repo). Enjoy!