Prevent tag refs in $(GitBranch) for detached heads.#127
Prevent tag refs in $(GitBranch) for detached heads.#127kzu merged 1 commit intodevlooped:masterfrom andersforsgren:ignore-tags-for-refname
Conversation
|
Awesome improvement and nice docs too! Thanks 💯 |
|
Heads up that this might need a tweak: It actually regressed to a worse state on our build servers with this version despite a fair bit of local testing. Turns out that if there are no refs (including no tags) at all in the working copy, the name-rev would return "remotes/origin/master~N". With the new default filter, remote branch names don't match the filter so it becomes "undefined" instead of "master", which is clearly worse. The correct thing to do is obviously to always pass in /p:GitBranch=whatever to the msbuild command when building for CI. But the question is what the correct thing to do is when it's not done.
|
|
Hm, I think using the hardcoded |
|
"detached-30ac81b" would make sense |
|
Sounds good! Could you send a PR? Thanks! |
|
Will do |
|
I looked at git name-rev docs and it has an argument "--always" that makes it return the shorthash in case it can't find another refname. I suggest just using that for simplicity, even though it means one gets just "shorthash" instead of "detached-shorthash". The alternative would involve detecting the nonzero error code or "undefined" name, and then doing another exec git rev-parse --short HEAD to get the hash. That seems a bit overkill for the purpose, so I'll do the simplest one. PR to add "--always" to the default args incoming. |
Changes the behavior of finding a value for $(GitBranch) when in detached head, common on CI servers. Fixes #126