-
Notifications
You must be signed in to change notification settings - Fork 285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix detached head state #139
Conversation
|
oh no! ==> centos-64-x64: Forcing shutdown of VM... Failures:
Finished in 1 minute 6.93 seconds |
| # reset instead of pull to avoid merge conflicts. assuming remote is | ||
| # authoritative. | ||
| # might be worthwhile to have an allow_local_changes param to decide | ||
| # whether to reset or pull when we're ensuring latest. | ||
| at_path { git_with_identity('reset', '--hard', "#{@resource.value(:remote)}/#{desired}") } | ||
| at_path { | ||
| git_with_identity('reset', '--hard', "#{@resource.value(:remote)}/#{@resource.value(:revision)}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not desired here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point we have already asserted that wear are on a branch. While we can't do a desired on the hard reset than checkout the branch immediately thereafter and then pull to resolve detached head
|
This is a case where using the git "chrome" layer can be trouble, because it changes over time (and has changed a lot across git versions on supported OS revisions). I would advise against using |
|
How about: git rev-parse --symbolic-full-name --abbrev-ref HEADon a branch, returns |
|
previously we were just seaing if we had git rev-parse --abbrev-ref HEAD but if we are using branches that is not the desired state. We want the latest for that branch that we have decided to call revision. |
|
Exited: 1 Finished in 1 minute 5.41 seconds |
|
I'm OK with this but I'm also a git idiot. It looks to me like it's doing the right thing, @sodabrew, did the change to -a help at all with your concerns? |
|
$ git branch -a | grep \*
* (detached from 3896638)If the current head is on a branch, there will be a line like this: $ git branch -a | grep \*
* masterI think it's fine actually, but the test data should be messier to make sure that the regex handles multilines correctly. I would warn that this is using the git "chrome" and the output is designed for human consumption rather than machine parsing and can change over time. |
|
Added multiline branch -a |
|
👍 |
Fix detached head state
No description provided.