Skip to content

Commit

Permalink
Fix version detection in case of missing .git folder
Browse files Browse the repository at this point in the history
  • Loading branch information
dolfinus committed Oct 7, 2020
1 parent 07addd8 commit bc7e350
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions setuptools_git_versioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,16 @@ def version_from_git(template=DEFAULT_TEMPLATE,

dirty = is_dirty()
head_sha = get_sha()
short_sha = head_sha[:8] if head_sha is not None else ''
ccount = count_since(tag_sha)
on_tag = head_sha == tag_sha and not from_file
on_tag = head_sha is not None and head_sha == tag_sha and not from_file
branch = get_branch()

if dirty:
t = dirty_template
elif not on_tag:
elif not on_tag and ccount is not None:
t = dev_template
else:
t = template

return t.format(sha=head_sha[:8], tag=tag, ccount=ccount, branch=branch)
return t.format(sha=short_sha, tag=tag, ccount=ccount, branch=branch)

0 comments on commit bc7e350

Please sign in to comment.