Remove git-committerconfig in favor for new go-tool
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
1f9e549a60
commit
55bd8d2eb8
1 changed files with 0 additions and 60 deletions
|
@ -1,60 +0,0 @@
|
||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
# Usage: git setmail
|
|
||||||
#
|
|
||||||
# Configuration format:
|
|
||||||
# [
|
|
||||||
# {
|
|
||||||
# "match": ".*",
|
|
||||||
# "email": "mymail@example.com",
|
|
||||||
# "signingkey": "...",
|
|
||||||
# }
|
|
||||||
# ]
|
|
||||||
|
|
||||||
import sys
|
|
||||||
import re
|
|
||||||
import subprocess
|
|
||||||
import os.path
|
|
||||||
import json
|
|
||||||
|
|
||||||
CONFIG = os.path.expanduser('~/.config/git-committerconfig.json')
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
try:
|
|
||||||
repo = [x.split()[1] for x
|
|
||||||
in subprocess.check_output(['git', 'remote', '-v'], universal_newlines=True).split('\n')
|
|
||||||
if re.match('origin.*\(push\)', x)][0]
|
|
||||||
except:
|
|
||||||
print('Could not find origin, not setting local git configuration.')
|
|
||||||
return 0
|
|
||||||
|
|
||||||
if os.path.isfile(CONFIG):
|
|
||||||
combinations = json.loads(open(CONFIG).read())
|
|
||||||
else:
|
|
||||||
print('Config ({}) found.'.format(CONFIG))
|
|
||||||
return 1
|
|
||||||
|
|
||||||
for combi in combinations:
|
|
||||||
if re.search(combi['match'], repo):
|
|
||||||
set_local_config('user.email', combi['email'])
|
|
||||||
|
|
||||||
if 'signingkey' in combi and combi['signingkey'] != '':
|
|
||||||
set_local_config('user.signingkey', combi['signingkey'])
|
|
||||||
set_local_config('gpg.format', 'ssh' if re.search(
|
|
||||||
r'^(?:ssh|ecdsa|key::)', combi['signingkey']) else 'openpgp')
|
|
||||||
|
|
||||||
if 'commit-opts' in combi:
|
|
||||||
set_local_config('commit.cliopts', combi['commit-opts'])
|
|
||||||
|
|
||||||
break
|
|
||||||
|
|
||||||
return 0
|
|
||||||
|
|
||||||
|
|
||||||
def set_local_config(param, value):
|
|
||||||
subprocess.check_call(['git', 'config', '--local', param, value])
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
exit(main())
|
|
Loading…
Reference in a new issue