Skip to content
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

Merged
merged 4 commits into from
May 19, 2014
Merged

Fix detached head state #139

merged 4 commits into from
May 19, 2014

Conversation

cyberious
Copy link

No description provided.

@apenney
Copy link

apenney commented May 16, 2014

oh no!

==> centos-64-x64: Forcing shutdown of VM...
==> centos-64-x64: Destroying VM and associated drives...

Failures:

  1. clones a remote repo ensure latest clones a repo
    Failure/Error: apply_manifest(pp, :catch_changes => true)
    Beaker::Host::CommandFailure:
    Host 'centos-64-x64' exited with 4 running:
    env PATH="/usr/bin:/opt/puppet-git-repos/hiera/bin:${PATH}" RUBYLIB="/opt/puppet-git-repos/hiera/lib:/opt/puppet-git-repos/hiera-puppet/lib:${RUBYLIB}" puppet apply --verbose --detailed-exitcodes /tmp/apply_manifest.pp.DcIGaW
    Last 10 lines of output were:
    -a list both remote-tracking and local branches
    -d delete fully merged branch
    -D delete branch (even if not merged)
    -m move/rename a branch and its reflog
    -M move/rename a branch, even if target exists
    -l create the branch's reflog
    -f, --force force creation (when already exists)
    --no-merged print only not merged branches
    --merged print only merged branches
    Notice: Finished catalog run in 0.41 seconds

    ./spec/acceptance/clone_repo_spec.rb:137:in `block (3 levels) in <top (required)>'

Finished in 1 minute 6.93 seconds
51 examples, 1 failure

# 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)}")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not desired here?

Copy link
Author

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

@sodabrew
Copy link

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 git branch in this way, if it's at all possible to use rev-parse and other "low level" git commands instead.

@sodabrew
Copy link

How about:

git rev-parse --symbolic-full-name --abbrev-ref HEAD

on a branch, returns brachname and detached, returns HEAD. Let's see if that works all the way back to git 1.5... ?

@cyberious
Copy link
Author

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.

@cyberious
Copy link
Author

Exited: 1
should not be directory
removing temporory ssh-config files per-vagrant box
Destroying vagrant boxes
WARNING: Could not load IOV methods. Check your GSSAPI C library for an update
WARNING: Could not load AEAD methods. Check your GSSAPI C library for an update
WARNING: Nokogiri was built against LibXML version 2.8.0, but has dynamically loaded 2.9.1
==> centos-64-x64: Forcing shutdown of VM...
==> centos-64-x64: Destroying VM and associated drives...

Finished in 1 minute 5.41 seconds
51 examples, 0 failures

@apenney
Copy link

apenney commented May 16, 2014

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?

@sodabrew
Copy link

git branch -a will return many lines with every available local and remote branch. If the current head is detached, there will be a line like this:

$ 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 \*
* master

I 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.

@cyberious
Copy link
Author

Added multiline branch -a

apenney pushed a commit that referenced this pull request May 19, 2014
@apenney apenney merged commit 0595996 into puppetlabs:master May 19, 2014
@sodabrew
Copy link

👍

cegeka-jenkins pushed a commit to cegeka/puppet-vcsrepo that referenced this pull request Jan 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants