Skip to content

Commit

Permalink
Add setting the default user name and email when adding new git based…
Browse files Browse the repository at this point in the history
… overlays. Bug 433687.
  • Loading branch information
dol-sen committed Oct 7, 2012
1 parent 2bc0b74 commit faf6c74
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
10 changes: 10 additions & 0 deletions etc/layman.cfg
Expand Up @@ -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


2 changes: 2 additions & 0 deletions layman/config.py
Expand Up @@ -134,6 +134,8 @@ def __init__(self, output=None, stdout=None, stdin=None, stderr=None,
'svn_postsync' : '',
'tar_postsync' : '',
'g-common_postsync' : '',
'git_user': 'layman',
'git_email': 'layman@localhost',
}
self._options = {
'config': config if config else self._defaults['config'],
Expand Down
28 changes: 22 additions & 6 deletions layman/overlays/git.py
Expand Up @@ -67,12 +67,28 @@ def fix_git_source(source):
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.'''
Expand Down

0 comments on commit faf6c74

Please sign in to comment.