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

git_helpers: add fallback for inconsistent describe #2

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion conda_build_prepare/git_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,11 @@ def _call_custom_git_cmd(git_repo, cmd_string, check=True, quiet=False):
def get_latest_describe_tag(git_repo):
# Find the `git describe` tag having any version-like part
proppy marked this conversation as resolved.
Show resolved Hide resolved
try:
return _call_custom_git_cmd(git_repo, 'describe --tags --abbrev=0', quiet=True)
describe_tag = _call_custom_git_cmd(git_repo, 'describe --tags --abbrev=0', quiet=True)
tag_commit = _call_custom_git_cmd(git_repo, f'git rev-list --tags -1')
alt_tag = _call_custom_git_cmd(git_repo, f'tag --points-at {tag_commit}')
# Prefer actual tag over `git describe' if inconsistent.
return describe_tag if describe_tag.startswith(alt_tag) else alt_tag
except subprocess.CalledProcessError:
return None

Expand Down