gyrojeff commited on
Commit
fdd1362
1 Parent(s): 211ae8a

feat: add vcs util

Browse files
Files changed (2) hide show
  1. utils/__init__.py +1 -0
  2. utils/vcs.py +11 -0
utils/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ from .vcs import get_current_tag
utils/vcs.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pathlib import Path
2
+
3
+ import pygit2
4
+
5
+
6
+ def get_current_tag() -> str:
7
+ repo = pygit2.Repository(Path(__file__).parent.absolute())
8
+ for file, val in repo.status().items():
9
+ if val != 1 << 14:
10
+ raise RuntimeError("Unstaged commit detected:", file, val)
11
+ return repo.head.peel().short_id