fix build.py script to work with detached heads
This commit is contained in:
parent
386e3f0e02
commit
d4e42d01f9
1 changed files with 12 additions and 5 deletions
15
build.py
15
build.py
|
@ -16,17 +16,24 @@ BUILD_DETAILS = [
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def get_latest_commit(repo):
|
||||||
|
if repo.head.is_detached:
|
||||||
|
return repo.head.commit
|
||||||
|
else:
|
||||||
|
return repo.head.ref.commit
|
||||||
|
|
||||||
|
|
||||||
def build_details():
|
def build_details():
|
||||||
repo = git.Repo()
|
repo = git.Repo()
|
||||||
repo_description = git_describe(repo.head.ref.commit)
|
repo_description = git_describe(get_latest_commit(repo))
|
||||||
pytex_repo = repo.submodule('PyTeX').module()
|
pytex_repo = repo.submodule('PyTeX').module()
|
||||||
pytex_repo_description = git_describe(pytex_repo.head.ref.commit)
|
pytex_repo_description = git_describe(get_latest_commit(pytex_repo))
|
||||||
return list(map(lambda line: line.format(
|
return list(map(lambda line: line.format(
|
||||||
build_time=datetime.now().strftime('%Y/%m/%d %H:%M'),
|
build_time=datetime.now().strftime('%Y/%m/%d %H:%M'),
|
||||||
pytex_version=pytex_repo_description,
|
pytex_version=pytex_repo_description,
|
||||||
pytex_commit_hash=pytex_repo.head.ref.commit.hexsha[0:7],
|
pytex_commit_hash=get_latest_commit(pytex_repo).hexsha[0:7],
|
||||||
packages_version=repo_description,
|
packages_version=repo_description,
|
||||||
packages_commit_hash=repo.head.ref.commit.hexsha[0:7]
|
packages_commit_hash=get_latest_commit(repo).hexsha[0:7]
|
||||||
), BUILD_DETAILS))
|
), BUILD_DETAILS))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue