Skip to content

Commit bc7e350

Browse files
committed
Fix version detection in case of missing .git folder
1 parent 07addd8 commit bc7e350

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

setuptools_git_versioning.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,16 @@ def version_from_git(template=DEFAULT_TEMPLATE,
167167

168168
dirty = is_dirty()
169169
head_sha = get_sha()
170+
short_sha = head_sha[:8] if head_sha is not None else ''
170171
ccount = count_since(tag_sha)
171-
on_tag = head_sha == tag_sha and not from_file
172+
on_tag = head_sha is not None and head_sha == tag_sha and not from_file
172173
branch = get_branch()
173174

174175
if dirty:
175176
t = dirty_template
176-
elif not on_tag:
177+
elif not on_tag and ccount is not None:
177178
t = dev_template
178179
else:
179180
t = template
180181

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

0 commit comments

Comments
 (0)