Skip to content
This repository has been archived by the owner on Jul 14, 2021. It is now read-only.

Don't error when profiling an unborn branch #392

Merged
merged 1 commit into from
May 12, 2015

Conversation

danielsdeleo
Copy link
Contributor

As described in #364 when you create a repo (git init) but don't have a commit, you're on an unborn master branch. Commands such as git rev-parse HEAD will fail in such a scenario, which causes most Policyfile commands to fail (when attempting to extract git information about the cookbook). There does not seem to be a canonical way to detect that you're on an unborn branch, git uses the same exit code for all failures, and the error messages printed to stderr do not seem to be stable across git versions. So I settled on feeding the output of git symbolic-ref -q HEAD to show-ref --verify $SYMBOLIC_REF (we expect the first command to succeed and the second command to fail on an unborn branch).

fixes #364

@chef/client-core @tyler-ball

@tyler-ball
Copy link
Contributor

👍 LGTM - and it passed on appveyor, woohoo!

@danielsdeleo danielsdeleo merged commit 54337f6 into master May 12, 2015
@danielsdeleo danielsdeleo deleted the detect-unborn-branch branch May 12, 2015 01:54
@chef-boneyard chef-boneyard locked and limited conversation to collaborators Feb 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Policyfile git detection blows up in a brand new repo
3 participants