Last active
October 2, 2015 04:37
-
-
Save dulyanov/2173284 to your computer and use it in GitHub Desktop.
Revisions
-
dulyanov revised this gist
Apr 24, 2013 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,8 +6,10 @@ # # Based on git://gist.github.com/750755.git # # Place code into .git/hooks/prepare-commit-msg and give it executable permissions # cd .git/hooks # wget https://gist.github.com/dulyanov/2173284/raw/prepare-commit-msg # chmod 755 prepare-commit-msg branchname = `git branch --no-color 2> /dev/null`[/^\* (.+)/, 1].strip -
dulyanov revised this gist
Apr 24, 2013 . 1 changed file with 4 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,10 +6,8 @@ # # Based on git://gist.github.com/750755.git # # Place code into .git/hooks/prepare-commit-msg # chmod 755 .git/hooks/prepare-commit-msg branchname = `git branch --no-color 2> /dev/null`[/^\* (.+)/, 1].strip @@ -20,7 +18,8 @@ prepend = "[#{branchname}] " # When task branch name is numeric and not a merge, use it for task number if branchname =~ /\d+/ && (message =~ /Merge branch.*into #{branchname}/).nil? task_number = branchname.gsub(/[^\d]/, '') prepend += "(Task #{task_number}) " end # When message is blank and starts with comments, add a line break -
dulyanov revised this gist
Apr 21, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,7 @@ # # Place code into .git/hooks/prepare-commit-msg and give it executable permissions # cd .git/hooks # wget https://gist.github.com/dulyanov/2173284/raw/prepare-commit-msg # chmod 755 prepare-commit-msg branchname = `git branch --no-color 2> /dev/null`[/^\* (.+)/, 1].strip -
dulyanov revised this gist
Apr 21, 2013 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,8 +6,10 @@ # # Based on git://gist.github.com/750755.git # # Place code into .git/hooks/prepare-commit-msg and give it executable permissions # cd .git/hooks # wget https://gist.github.com/dulyanov/2173284/raw/b0e9cfacc3773e6d5181ff11ea4d1c255b3952d4/prepare-commit-msg # chmod 755 prepare-commit-msg branchname = `git branch --no-color 2> /dev/null`[/^\* (.+)/, 1].strip -
dulyanov created this gist
Mar 23, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ #!/usr/bin/env ruby # # Git commit-msg hook. Prepend branch name to commit tasks. # If your branch name is in the numeric form "12345", also prepend "(Task 123)" to commit messages, # unless #notask is included in the message (#notask will be stripped). # # Based on git://gist.github.com/750755.git # # Place code into .git/hooks/prepare-commit-msg # chmod 755 .git/hooks/prepare-commit-msg branchname = `git branch --no-color 2> /dev/null`[/^\* (.+)/, 1].strip message_file = ARGV[0] message = File.read(message_file).strip prepend = "[#{branchname}] " # When task branch name is numeric and not a merge, use it for task number if branchname =~ /\d+/ && (message =~ /Merge branch.*into #{branchname}/).nil? prepend += "(Task #{branchname}) " end # When message is blank and starts with comments, add a line break prepend += "\n" if message.chars.first == "#" if message.include?("#notask") message.sub!(/^\s*#notask\s*|\s*#notask/, '') else message = prepend + message end File.open(message_file, 'w') {|f| f.write message }