Autopep8 and port to python3
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
2387473854
commit
3f9c6dc4c3
1 changed files with 36 additions and 27 deletions
|
@ -1,6 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from __future__ import print_function
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Usage: git setmail
|
||||
#
|
||||
|
@ -13,13 +11,20 @@ from __future__ import print_function
|
|||
# }
|
||||
# ]
|
||||
|
||||
import sys, re, subprocess, os.path, json
|
||||
import sys
|
||||
import re
|
||||
import subprocess
|
||||
import os.path
|
||||
import json
|
||||
|
||||
CONFIG = os.path.expanduser('~/.config/git-committerconfig.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']).split('\n') if re.match('origin.*\(push\)', x)][0]
|
||||
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 email.')
|
||||
return 0
|
||||
|
@ -32,14 +37,18 @@ def main():
|
|||
|
||||
for combi in combinations:
|
||||
if re.search(combi['match'], repo):
|
||||
subprocess.check_call(['git', 'config', '--local', 'user.email', combi['email']])
|
||||
subprocess.check_call(
|
||||
['git', 'config', '--local', 'user.email', combi['email']])
|
||||
if 'gpg-key' in combi and combi['gpg-key'] != '':
|
||||
subprocess.check_call(['git', 'config', '--local', 'user.signingkey', combi['gpg-key']])
|
||||
subprocess.check_call(
|
||||
['git', 'config', '--local', 'user.signingkey', combi['gpg-key']])
|
||||
if 'commit-opts' in combi:
|
||||
subprocess.check_call(['git', 'config', '--local', 'commit.cliopts', combi['commit-opts']])
|
||||
subprocess.check_call(
|
||||
['git', 'config', '--local', 'commit.cliopts', combi['commit-opts']])
|
||||
break
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
exit(main())
|
||||
|
|
Loading…
Reference in a new issue