I need to know what branch I’m to do certain things based on the branch being run. I can’t see any way to do this with the current set of Git-based actions.
If there is a way, please let me know. If there isn’t currently a way, could you please create such an action.
Based on some googling, here are the commands to get just the current branch name out of Git. These don’t work on detached HEADs.
git symbolic-ref HEAD (Shows full refspec, v1.8+)
git symbolic-ref --short HEAD (just the branch name, v1.8+)
git rev-parse --abrev-ref HEAD (just branch name, v1.7+)
of course, in all versions you can just do “git branch” and find the entry with the asterisk.
I was trying to look for an action that allows you to run something form the command prompt and act on its output, but I couldn’t not find one.
I figured it out on my own, but it would be nice if this was baked into its own action.
My solution was to log the output of a “Git Generic” into a variable, using one of the commands from my previous post. Then used SubString and Trimming actions.