-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprepare-commit-msg
More file actions
executable file
·40 lines (27 loc) · 914 Bytes
/
prepare-commit-msg
File metadata and controls
executable file
·40 lines (27 loc) · 914 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
36
37
38
39
40
#!/usr/bin/env python3
import subprocess
import sys
SSID_LOCATION_MAP = {"Noisebridge Cap": "Noisebridge"}
def getSSID():
result = subprocess.run(["ipconfig", "getsummary", "en0"],
capture_output=True,
text=True,
check=True)
for line in result.stdout.split('\n'):
if ' SSID' in line:
ssid = line.split(':', 1)[1].strip()
return ssid
print("authored-at: Couldn't get SSID.")
return None
def addAuthoredAt(msgFile, location):
with open(msgFile, 'a') as f:
f.write(f"\nAuthored-at: {location}\n")
if __name__ == "__main__":
if len(sys.argv) < 2:
sys.exit(1)
msgFile = sys.argv[1]
ssid = getSSID()
if ssid and ssid in SSID_LOCATION_MAP:
location = SSID_LOCATION_MAP[ssid]
addAuthoredAt(msgFile, location)
sys.exit(0)