diff --git a/bin/git-committerconfig b/bin/git-committerconfig deleted file mode 100755 index 7bf83f2..0000000 --- a/bin/git-committerconfig +++ /dev/null @@ -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())