Created
August 20, 2011 09:00
-
-
Save schacon/1158878 to your computer and use it in GitHub Desktop.
Annotating pushed commits with the pusher
This file contains 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 characters
$ git log --notes=pusher | |
commit c5ba11b523db159b319f568931501237c5e53ed2 | |
Author: Scott Chacon <[email protected]> | |
Date: Sat Aug 20 10:59:02 2011 +0200 | |
test | |
Notes (pusher): | |
master :: User Name [email protected] :: Sat Aug 20 10:59:02 +0200 2011 | |
commit 7a543be441fe571470542d05a4a611920ff1a423 | |
Author: Scott Chacon <[email protected]> | |
Date: Sat Aug 20 10:57:46 2011 +0200 | |
test | |
Notes (pusher): | |
master :: User Name [email protected] :: Sat Aug 20 10:57:46 +0200 2011 |
This file contains 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 characters
#!/usr/bin/env ruby | |
refname = ARGV[0] | |
oldrev = ARGV[1] | |
newrev = ARGV[2] | |
puts "#{refname} #{oldrev} #{newrev}" | |
# NOTE: replace this with the credentials of the authenticated user | |
pusher = "User Name [email protected]" | |
# NOTE: optionally replace this with the notes ref you want to use | |
note_ref = "refs/notes/pusher" | |
sref = refname.gsub('refs/heads/', '') | |
push_str = sref + ' :: ' + pusher + ' :: ' + Time.now.to_s | |
# add a pusher note | |
data = `git rev-list #{oldrev}..#{newrev}`.chomp | |
shas = data.split("\n") | |
shas.each do |sha| | |
`git notes --ref #{note_ref} append -m "#{push_str}" #{sha}` | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment