diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2013-03-01 18:04:40 +0000 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2013-03-01 18:04:40 +0000 |
commit | c11cdb16e2d10e29c96873db5796e911979012d8 (patch) | |
tree | ef14e3fab90c6719b28a98d37f9329e93e606b2f /morphlib/git.py | |
parent | 1b16bb71e792228302cd7bb9dabef9220c7ca5b1 (diff) | |
parent | d884a94133ae4b78138cb0a1d9f1ccfcc0061b1e (diff) | |
download | morph-c11cdb16e2d10e29c96873db5796e911979012d8.tar.gz |
Merge branch 'baserock/richardmaw/branch-and-merge-git-config-warnings-v2' of git://git.baserock.org/baserock/baserock/morphbaserock/genivi/baseline/releases/F-0.1
Reviewed-by: Sam Thursfield
Reviewed-by: Lars Wirzenius
Diffstat (limited to 'morphlib/git.py')
-rw-r--r-- | morphlib/git.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/morphlib/git.py b/morphlib/git.py index c63c21b2..fffc05d0 100644 --- a/morphlib/git.py +++ b/morphlib/git.py @@ -183,6 +183,23 @@ def get_user_email(runcmd): ' git config --global user.email "me@example.com"\n') +def check_config_set(runcmd, keys=("user.name", "user.email"), cwd='.'): + ''' Check whether the given keys have values in git config. ''' + missing = [] + for key in keys: + try: + runcmd(['git', 'config', key], cwd=cwd) + except cliapp.AppException: + missing.append(key) + if missing: + if len(missing) == 1: + emesg = 'Git configuration for %s has not been set' % missing[0] + else: + emesg = ('Git configuration for keys %s and %s have not been set' + % (', '.join(missing[:-1]), missing[-1])) + raise cliapp.AppException(emesg) + + def set_remote(runcmd, gitdir, name, url): '''Set remote with name 'name' use a given url at gitdir''' return runcmd(['git', 'remote', 'set-url', name, url], cwd=gitdir) |