Skip to content

Instantly share code, notes, and snippets.

@dhollinger
Created November 15, 2017 22:42
Show Gist options
  • Save dhollinger/c242caba58b8aef646a0b84420cfd3fb to your computer and use it in GitHub Desktop.
Save dhollinger/c242caba58b8aef646a0b84420cfd3fb to your computer and use it in GitHub Desktop.
def branch
case @vcs
when 'github'
if @data.key? 'ref'
@data['ref'].sub('refs/heads/', '')
else
@data['repository']['default_branch']
end
when 'gitlab'
@data['ref'].sub('refs/heads/', '')
when 'stash'
@data['refChanges'][0]['refId'].sub('refs/heads/', '')
when 'bitbucket'
return @data['push']['changes'][0]['new']['name'] unless @data['push']['changes'][0]['new'].nil?
@data['push']['changes'][0]['old']['name']
when 'tfs'
@data['resource']['refUpdates'][0]['name'].sub('refs/heads/', '')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment