Inspirated

 
 

August 23, 2011

Tarball generator for Git commits

Filed under: Blog — krkhan @ 12:56 am

While working for GSoC last year I kept track of Bazaar patches I sent in for Arsenal. This year I was using Git and as the need arose to generate a submission tarball for my commits I wrote this small utility script: git-generate-tarball.py.

To invoke the script, change into your Git repository and provide an author name and a file as an argument:

[krkhan@orthanc tor]$ /home/krkhan/Downloads/git-generate-tarball.py "Kamran Riaz Khan " /home/krkhan/Downloads/tor-gsoc-krkhan.tar.gz

generating tarball for commits between Mon May 23 00:00:00 2011 +0000 and Mon Aug 22 19:00:00 2011 +0000
generating patch for commit 5a801a8c8b71c9551a80913398135809cb10cecd

/home/krkhan/Downloads/tor-gsoc-krkhan.tar.gz created

The default starting and ending dates for the commits correspond to the schedule for GSoC 2011. You can specify a starting date for the commits you want to be packaged using the --since argument:

[krkhan@orthanc arm]$ /home/krkhan/Downloads/git-generate-tarball.py --since="August 1, 2011" "Kamran Riaz Khan " /home/krkhan/Downloads/arm-gsoc-krkhan.tar.bz2

generating tarball for commits between August 1, 2011 and Mon Aug 22 19:00:00 2011 +0000
generating patch for commit 546ca73259d7863e3efe5e11e09c023c2790a2f6

/home/krkhan/Downloads/arm-gsoc-krkhan.tar.bz2 created

Same goes for the --before argument:

[krkhan@orthanc tor]$ /home/krkhan/Downloads/git-generate-tarball.py --before="August 14, 2011" "Kamran Riaz Khan " /home/krkhan/Downloads/tor-gsoc-krkhan.tar.gz

generating tarball for commits between Mon May 23 00:00:00 2011 +0000 and August 14, 2011
generating patch for commit 5a801a8c8b71c9551a80913398135809cb10cecd

/home/krkhan/Downloads/tor-gsoc-krkhan.tar.gz created

Or a combination of both:

[krkhan@orthanc arm]$ /home/krkhan/Downloads/git-generate-tarball.py --since="August 1, 2011" --before="August 14, 2011" "Kamran Riaz Khan " /home/krkhan/Downloads/arm-gsoc-krkhan.tar.gz

generating tarball for commits between August 1, 2011 and August 14, 2011
generating patch for commit 546ca73259d7863e3efe5e11e09c023c2790a2f6

/home/krkhan/Downloads/arm-gsoc-krkhan.tar.gz created

If you want to leave the dates undefined you can leave the arguments empty. For example, the following command shall process all commits before June 1, 2011:

[krkhan@orthanc arm]$ /home/krkhan/Downloads/git-generate-tarball.py --since= --before="June 1, 2011" "Kamran Riaz Khan " /home/krkhan/Downloads/arm-gsoc-krkhan.tar.gz

generating tarball for commits before June 1, 2011
generating patch for commit 8b4dc162f75d5129e41f028c7253b7b265c8af76

/home/krkhan/Downloads/arm-gsoc-krkhan.tar.gz created

Hope this helps fellow GSoCers.

Tags: , , , , ,

5 Comments

  1. That is really great! Thanks :)

    Comment by alfongj — August 23, 2011 @ 12:21 pm

  2. We want a post regarding the recent update -_-!

    Comment by NP — August 24, 2011 @ 1:18 am

  3. i second that . humph :p

    Comment by meenie — August 24, 2011 @ 6:29 pm

  4. The Python documentation mentions that using Popen.wait() will deadlock when using stdout=PIPE and the git process generates more than a certain amount of output. You should consider changing that to communicate().

    Other than that, thanks for your work.

    Comment by Clemens — August 25, 2011 @ 2:22 am

  5. Thanks for pointing that out Clemens. As it turns out the wait() call was redundant anyway as I was using communicate() on the next line. I’ve updated the tarball with the fix.

    Comment by krkhan — August 25, 2011 @ 6:11 am

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.