Skip to content

Instantly share code, notes, and snippets.

@schacon
Created August 20, 2011 09:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schacon/1158878 to your computer and use it in GitHub Desktop.
Save schacon/1158878 to your computer and use it in GitHub Desktop.
Annotating pushed commits with the pusher
$ git log --notes=pusher
commit c5ba11b523db159b319f568931501237c5e53ed2
Author: Scott Chacon <schacon@gmail.com>
Date: Sat Aug 20 10:59:02 2011 +0200
test
Notes (pusher):
master :: User Name user@name.com :: Sat Aug 20 10:59:02 +0200 2011
commit 7a543be441fe571470542d05a4a611920ff1a423
Author: Scott Chacon <schacon@gmail.com>
Date: Sat Aug 20 10:57:46 2011 +0200
test
Notes (pusher):
master :: User Name user@name.com :: Sat Aug 20 10:57:46 +0200 2011
#!/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 user@name.com"
# 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