Created
November 15, 2017 22:42
-
-
Save dhollinger/c242caba58b8aef646a0b84420cfd3fb to your computer and use it in GitHub Desktop.
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 characters
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