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

Use git rev-parse to get tag canonical revision #120

Merged
merged 1 commit into from Apr 3, 2014

Conversation

huandu
Copy link

@huandu huandu commented Feb 12, 2014

git rev-parse is preferred to get tag's canonical revision. And a side effect of this PR is to fix #112 per my test.

@sodabrew
Copy link

This makes sense. But let's also squash the if conditions together. I can submit a separate PR, but here's what I'm thinking:

    canonical = at_path { git_with_identity('rev-parse', '--revs-only', @resource.value(:revision)).chomp }
    if canonical.empty? && tag_revision?(@resource.value(:revision))
      # git rev-parse executed properly but didn't find the ref;
      # look for it in the remote
      remote_ref = at_path { git_with_identity('ls-remote', '--heads', '--tags', @resource.value(:remote), @resource.value(:revision)).chomp }
      if remote_ref.empty?
        fail("#{@resource.value(:revision)} is not a local or remote ref")
      end

      # $ git ls-remote --heads --tags origin feature/cvs
      # 7d4244b35e72904e30130cad6d2258f901c16f1a    refs/heads/feature/cvs
      canonical = remote_ref.split.first
    end

@sodabrew
Copy link

I'm not sure why we wouldn't look at the remote in case the revision is a tag.

@huandu
Copy link
Author

huandu commented Feb 13, 2014

@sodabrew A possible reason for your question is that tag_revision? only checks local tags. If a tag is not recognized as local tag, the else branch will be executed so that the tag will be looked at remote.

apenney pushed a commit that referenced this pull request Apr 3, 2014
Use `git rev-parse` to get tag canonical revision
@apenney apenney merged commit 46588aa into puppetlabs:master Apr 3, 2014
@sodabrew
Copy link

sodabrew commented Apr 3, 2014

@apenney I'll submit a PR per #120 (comment) :)

cegeka-jenkins pushed a commit to cegeka/puppet-vcsrepo that referenced this pull request Jan 3, 2018
Use `git rev-parse` to get tag canonical revision
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants