diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2012-09-13 12:08:03 +0000 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2012-09-13 12:08:03 +0000 |
commit | 9e95e4a72d875d201dfdb012f217181788eec7f1 (patch) | |
tree | 9cba3580ab766c7def3307089ef3c1d07415192e /morphlib | |
parent | 2a38d6b1a1702c1de0e684714d1056049f546515 (diff) | |
parent | ef0b21be1845d69886bd84f402725e439fc928b4 (diff) | |
download | morph-9e95e4a72d875d201dfdb012f217181788eec7f1.tar.gz |
Merge branch 'samthursfield/S4712-handle-no-git-user-info' of git://roadtrain.codethink.co.uk/baserock/morph
Diffstat (limited to 'morphlib')
-rw-r--r-- | morphlib/git.py | 12 | ||||
-rw-r--r-- | morphlib/plugins/branch_and_merge_plugin.py | 4 |
2 files changed, 14 insertions, 2 deletions
diff --git a/morphlib/git.py b/morphlib/git.py index 0a4b01f4..d8169c93 100644 --- a/morphlib/git.py +++ b/morphlib/git.py @@ -135,6 +135,18 @@ class Submodules(object): def __len__(self): return len(self.submodules) +def get_user_name(runcmd): + '''Get user.name configuration setting. Complain if none was found.''' + if 'GIT_AUTHOR_NAME' in os.environ: + return os.environ['GIT_AUTHOR_NAME'].strip() + try: + return runcmd(['git', 'config', 'user.name']).strip() + except cliapp.AppException: + raise cliapp.AppException( + 'No git user info found. Please set your identity, using: \n' + ' git config --global user.name "My Name"\n' + ' git config --global user.email "me@example.com"\n') + def set_remote(runcmd, gitdir, name, url): '''Set remote with name 'name' use a given url at gitdir''' diff --git a/morphlib/plugins/branch_and_merge_plugin.py b/morphlib/plugins/branch_and_merge_plugin.py index a1afd25d..48e29063 100644 --- a/morphlib/plugins/branch_and_merge_plugin.py +++ b/morphlib/plugins/branch_and_merge_plugin.py @@ -784,9 +784,9 @@ class BranchAndMergePlugin(cliapp.Plugin): def update_build_refs(self, build_repos, system_branch, build_uuid): # Define the committer. committer_name = 'Morph (on behalf of %s)' % \ - self.app.runcmd(['git', 'config', 'user.name']).strip() + (morphlib.git.get_user_name(self.app.runcmd)) committer_email = '%s@%s' % \ - (os.environ.get('LOGNAME'), socket.gethostname()) + (os.environ.get('LOGNAME'), socket.gethostname()) for repo, info in build_repos.iteritems(): repo_dir = info['dirname'] |