4

This has already been asked here but was not answered as far as I can see.

I am writing a script to automate git workflow. When a topic branch is created it automatically creates a github issue referencing it - is there any way to automatically prepend this issue number to all commits made in that branch? I am thinking there may be a way using git hooks but I'm unable to find it.

I am aware that manually adding #xxx to the beginning of each commit message will do this; what I am interested in (and what was never answered in the original question) is if there is a way for this to be added automatically.

Community
  • 1
  • 1
omnikron
  • 2,211
  • 17
  • 30
  • http://henrik.nyh.se/2009/09/git-hook-to-auto-reference-tickets-from-the-branchname might be worth a read. It references tickets from the branch name though, but it might be a start. – Frost Jan 18 '12 at 10:17
  • Thanks, that's a great article that I hadn't seen before. Looks like I should be able to fork it and bend it to my will! – omnikron Jan 18 '12 at 10:39
  • @Frost I think your comment is worth being turned into a real answer. – nulltoken Jan 18 '12 at 22:11

1 Answers1

3

Have a look at how Henrik Nyh did a similar thing, by extracting issue numbers from branch names. You might be able to get something out of that.

Henrik's article is here.

Frost
  • 11,121
  • 3
  • 37
  • 44
  • 1
    Thanks again for this, I was indeed able to get it working with my script. Here's my fork if anybody is interested: https://gist.github.com/1632375 – omnikron Jan 20 '12 at 13:18