diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2012-09-11 15:50:08 +0100 |
---|---|---|
committer | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2012-09-13 12:01:39 +0100 |
commit | 8c87a657236c64ff640589e2d27cb0b347f3691a (patch) | |
tree | 9ab553e0fd3f08c5f57f3332de3f2d9ec8933932 /morphlib/git.py | |
parent | 2a38d6b1a1702c1de0e684714d1056049f546515 (diff) | |
download | morph-8c87a657236c64ff640589e2d27cb0b347f3691a.tar.gz |
build: Fail if user hasn't set user.name (or GIT_AUTHOR_NAME)
Users in a VM may be running as 'root' so inferring from the username
is often useless. Since build branches are pushed to a server it is
useful to enforce useful onwership info.
Diffstat (limited to 'morphlib/git.py')
-rw-r--r-- | morphlib/git.py | 12 |
1 files changed, 12 insertions, 0 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''' |