summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2016-05-05 09:52:02 -0400
committerTim-Philipp Müller <tim@centricular.com>2016-05-08 18:06:34 +0100
commit9c818b8ca1f0f3a411c8b1b9659a1e1dd6a78b3f (patch)
treeac286b5d1bce80fd733ba46c124f3019b174b76b
parent62a126830bff775cf5511a7d8072a2363a77d354 (diff)
cerbero/git: Only set user if none is already configured
https://bugzilla.gnome.org/show_bug.cgi?id=766026
-rw-r--r--cerbero/utils/git.py25
1 files changed, 17 insertions, 8 deletions
diff --git a/cerbero/utils/git.py b/cerbero/utils/git.py
index 3bebdc03..d3b4f00a 100644
--- a/cerbero/utils/git.py
+++ b/cerbero/utils/git.py
@@ -21,11 +21,26 @@ import shutil
from cerbero.config import Platform
from cerbero.utils import shell
+from cerbero.errors import FatalError
GIT = 'git'
+def ensure_user_is_set(git_dir):
+ # Set the user configuration for this repository so that Cerbero never warns
+ # about it or errors out (it errors out with git-for-windows)
+ try:
+ shell.call('%s config user.email' % GIT)
+ except FatalError:
+ shell.call('%s config user.email "cerbero@gstreamer.freedesktop.org"' %
+ GIT, git_dir)
+
+ try:
+ shell.call('%s config user.name' % GIT)
+ except FatalError:
+ shell.call('%s config user.name "Cerbero Build System"' % GIT, git_dir)
+
def init(git_dir):
'''
Initialize a git repository with 'git init'
@@ -35,10 +50,7 @@ def init(git_dir):
'''
shell.call('mkdir -p %s' % git_dir)
shell.call('%s init' % GIT, git_dir)
- # Set the user configuration for this repository so that Cerbero never warns
- # about it or errors out (it errors out with git-for-windows)
- shell.call('%s config user.email "cerbero@gstreamer.freedesktop.org"' % GIT, git_dir)
- shell.call('%s config user.name "Cerbero Build System"' % GIT, git_dir)
+ ensure_user_is_set(git_dir)
def clean(git_dir):
@@ -192,10 +204,7 @@ def local_checkout(git_dir, local_git_dir, commit):
shell.call('%s reset --hard %s' % (GIT, commit), local_git_dir)
shell.call('%s clone %s -s -b %s .' % (GIT, local_git_dir, branch_name),
git_dir)
- # Set the user configuration for this repository so that Cerbero never warns
- # about it or errors out (it errors out with git-for-windows)
- shell.call('%s config user.email "cerbero@gstreamer.freedesktop.org"' % GIT, git_dir)
- shell.call('%s config user.name "Cerbero Build System"' % GIT, git_dir)
+ ensure_user_is_set(local_git_dir)
submodules_update(git_dir, local_git_dir)
def add_remote(git_dir, name, url):