summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Dolbec2012-10-07 23:38:41 (GMT)
committerBrian Dolbec2012-10-07 23:38:41 (GMT)
commitfaf6c74c1aa866d62137dcf203b3bca7a0e32634 (patch)
tree9e83551c6b7aedbf4be355dc6a56e7d26562f4c9
parent2bc0b7478a14a9bf95a2e3728ed5a5f8d755e9b1 (diff)
Add setting the default user name and email when adding new git based overlays. Bug 433687.
-rw-r--r--etc/layman.cfg10
-rw-r--r--layman/config.py2
-rw-r--r--layman/overlays/git.py28
3 files changed, 34 insertions, 6 deletions
diff --git a/etc/layman.cfg b/etc/layman.cfg
index 7f7baab..a99ab9d 100644
--- a/etc/layman.cfg
+++ b/etc/layman.cfg
@@ -188,3 +188,13 @@ news_reporter: portage
#tar_postsync :
#g-common_postsync :
+
+#-----------------------------------------------------------
+# Layman user info
+#
+# The user name and email to use when adding new repos
+#
+#git_user : layman
+#git_email : layman@localhost
+
+
diff --git a/layman/config.py b/layman/config.py
index 8430221..8ac3ebf 100644
--- a/layman/config.py
+++ b/layman/config.py
@@ -134,6 +134,8 @@ class BareConfig(object):
'svn_postsync' : '',
'tar_postsync' : '',
'g-common_postsync' : '',
+ 'git_user': 'layman',
+ 'git_email': 'layman@localhost',
}
self._options = {
'config': config if config else self._defaults['config'],
diff --git a/layman/overlays/git.py b/layman/overlays/git.py
index 308c81f..e15f26d 100644
--- a/layman/overlays/git.py
+++ b/layman/overlays/git.py
@@ -67,12 +67,28 @@ class GitOverlay(OverlaySource):
args.append(cfg_opts)
args.append(fix_git_source(self.src))
args.append(target)
- return self.postsync(
- # adding cwd=base due to a new git bug in selinux due to
- # not having user_home_dir_t and portage_fetch_t permissions
- # but changing dir works around it.
- self.run_command(self.command(), args, cmd=self.type, cwd=base),
- cwd=target)
+ success = False
+ # adding cwd=base due to a new git bug in selinux due to
+ # not having user_home_dir_t and portage_fetch_t permissions
+ # but changing dir works around it.
+ success = self.run_command(self.command(), args, cmd=self.type, cwd=base)
+ self.output.debug("cloned git repo...success=%s" % str(success), 8)
+ success = self.set_user(target)
+ return self.postsync(success, cwd=target)
+
+ def set_user(self, target):
+ '''Set dummy user.name and user.email to prevent possible errors'''
+ user = '"%s"' % self.config['git_user']
+ email = '"%s"' % self.config['git_email']
+ args = ['config', 'user.name', user]
+ self.output.debug("set git user info...args=%s" % ' '.join(args), 8)
+ failure = self.run_command(self.command(), args, cmd=self.type, cwd=target)
+ if failure:
+ self.output.debug("set git user info...failure setting name")
+ return failure
+ args = ['config', 'user.email', email]
+ self.output.debug("set git user info...args=%s" % ' '.join(args), 8)
+ return self.run_command(self.command(), args, cmd=self.type, cwd=target)
def sync(self, base):
'''Sync overlay.'''