Skip to content

Commit

Permalink
Merge pull request #5 from tannewt/fix_no_releases
Browse files Browse the repository at this point in the history
Determine version even when no tags exist in the repo.
  • Loading branch information
dhalbert authored Dec 26, 2017
2 parents 0684d8c + 5ebe5d4 commit 4f264c7
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions circuitpython_build_tools/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,16 @@ def version_string(path=None, *, valid_semver=False):
if tag.returncode == 0:
version = tag.stdout.strip().decode("utf-8", "strict")
else:
describe = subprocess.run("git describe --tags", shell=True, stdout=subprocess.PIPE, cwd=path)
tag, additional_commits, commitish = describe.stdout.strip().decode("utf-8", "strict").rsplit("-", maxsplit=2)
commitish = commitish[1:]
describe = subprocess.run("git describe --tags --always", shell=True, stdout=subprocess.PIPE, cwd=path)
describe = describe.stdout.strip().decode("utf-8", "strict").rsplit("-", maxsplit=2)
if len(describe) == 3:
tag, additional_commits, commitish = describe.stdout.strip().decode("utf-8", "strict").rsplit("-", maxsplit=2)
commitish = commitish[1:]
else:
tag = "0.0.0"
commit_count = subprocess.run("git rev-list --count HEAD", shell=True, stdout=subprocess.PIPE, cwd=path)
additional_commits = commit_count.stdout.strip().decode("utf-8", "strict")
commitish = describe[0]
if valid_semver:
version_info = semver.parse_version_info(tag)
if not version_info.prerelease:
Expand Down

0 comments on commit 4f264c7

Please sign in to comment.