-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit.py
More file actions
19 lines (15 loc) · 803 Bytes
/
git.py
File metadata and controls
19 lines (15 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import subprocess
# get folder commit hash
def get_commit_hash(folder_path):
result = subprocess.run(['git', 'rev-parse', 'HEAD'], cwd=folder_path, capture_output=True, text=True)
return result.stdout.strip()
# get folder upstream url
def get_upstream_url(folder_path):
result = subprocess.run(['git', 'config', '--get', 'remote.origin.url'], cwd=folder_path, capture_output=True, text=True)
return result.stdout.strip()
def get_branch_name(folder_path):
result = subprocess.run(['git', 'rev-parse', '--abbrev-ref', 'HEAD'], cwd=folder_path, capture_output=True, text=True)
return result.stdout.strip()
def get_tag_name(folder_path):
result = subprocess.run(['git', 'describe', '--tags'], cwd=folder_path, capture_output=True, text=True)
return result.stdout.strip()