|
|
|
I can, but it would be nicer to have it done automatically, even if there's a checkbox I have to click to enable it.
I do not think it is a good idea to put that one into checkout workflow directly as the most important thing is to make sure the source used across the build remains consistent.
I agree that it should be consistent. That's why I shared code that confirms consistency before checking out the branch. And assuming you are setting the checkout revision during snapshot by looking at the remote branch pointer before the build starts, the simpler method of running 'checkout -f' internally is safe and consistent because that's where the branch pointer was as the time of snapshot and all nodes will set their branch pointer to that same revision. A 'checkout -f' is safe to combine with a subsequent tag step because you haven't diverged the branch between local/remote (you only push the tag, not the local branch pointer).
When you're already taking the resource hit to fetch the entire repo it's frustrating to not have the benefit of regular branch checkout without custom steps/code. I'd be more understanding if you were doing shallow clones that would require further network traffic and disk space to get from detached HEAD to branch. Sorry we'd rather not to add that extra option to further complicate the already complicated git repository definition, as we only hear very few users having this requirement (changing SCM information during build). Also QB suggests not to modify the source code during build and putting code in detached head instead of branch serves our primary purpose.
Or a script to call below:
repositories.get("repo name").switchToHead();
|
git checkout <your branch>