swipely / jenkins-git-notes-plugin

22 stars 6 forks source link

Fix overriding notes bug and add tests #3

Closed tucker250 closed 12 years ago

tucker250 commented 12 years ago

@bfulton - First pass at a fix for losing git note history, and a refac to make it possible to unit test the plugin. The core change to fix the bug was to make the git note addition work like this:

  1. git fetch -f origin refs/notes/jenkins:refs/notes/jenkins
  2. prev_note = git notes --ref=jenkins show HEAD
  3. git notes --ref=jenkins add -f -m "{:data => value, previous_note => $prev}" HEAD
  4. git push origin refs/notes/jenkins

Since a race is possible here if two workers are adding a note to the same commit, if step 4 fails then we restart from step one. Note that the push in step 4 is not forced, and the pull in step 1 is. GitNotesPublisher will retry up to 3 times before giving up.

One open question is what "giving up on a git note" should entail. Should the build fail?

bfulton commented 12 years ago

@tucker250: Addressed concerns in latest commit. Merging.