-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost-commit
More file actions
executable file
·36 lines (27 loc) · 909 Bytes
/
post-commit
File metadata and controls
executable file
·36 lines (27 loc) · 909 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python
import sys
import os
import gitautoversion as gita
LOCKFILE = ".skip-post-commit-hook.lock"
if os.path.isfile(LOCKFILE):
sys.exit(0)
print("git-auto-version[post-commit]: updating version tags and ChangeLog.md")
# update change log
commits = gita.gitlog(last_hash=False)
gita.gittags(commits, update_commits=True)
changelog = gita.changelog(commits)
with open("ChangeLog.md", "w") as f:
f.write(changelog)
# update (ammend) the commit with the update change log
os.system("git add ChangeLog.md")
open(LOCKFILE, "w").close()
os.system("git commit --amend --no-edit")
os.remove(LOCKFILE)
# set version tags
commits = gita.gitlog()
tags = gita.gittags(commits)
for (hsh, ver) in tags:
tag = gita.gitversion(ver)
cmd = f"git tag -a {tag} {hsh} -m 'Version {tag}'"
print(f"git-auto-version[post-commit]: settting version tag {tag} for commit {hsh}")
os.system(cmd)