diff --git a/gbp/git/repository.py b/gbp/git/repository.py index 6cc3cd9f..fdca52a8 100644 --- a/gbp/git/repository.py +++ b/gbp/git/repository.py @@ -134,7 +134,7 @@ def __init__(self, path, toplevel=True): def __build_env(extra_env): """Prepare environment for subprocess calls""" env = None - if extra_env is not None: + if extra_env: env = os.environ.copy() env.update(extra_env) return env @@ -1450,11 +1450,14 @@ def rename_file(self, old, new): #{ Comitting - def _commit(self, msg, args=[], author_info=None): - extra_env = author_info.get_author_env() if author_info else None + def _commit(self, msg, args=[], author_info=None, committer_info=None): + extra_env = author_info.get_author_env() if author_info else {} + if committer_info: + extra_env.update(committer_info.get_committer_env()) self._git_command("commit", ['-q', '-m', msg] + args, extra_env=extra_env) - def commit_staged(self, msg, author_info=None, edit=False): + def commit_staged(self, msg, author_info=None, edit=False, + committer_info=None): """ Commit currently staged files to the repository @@ -1464,24 +1467,30 @@ def commit_staged(self, msg, author_info=None, edit=False): @type author_info: L{GitModifier} @param edit: whether to spawn an editor to edit the commit info @type edit: C{bool} + @param committer_info: committer information + @type committer_info: L{GitModifier} """ args = GitArgs() args.add_true(edit, '--edit') - self._commit(msg=msg, args=args.args, author_info=author_info) + self._commit(msg=msg, args=args.args, author_info=author_info, + committer_info=committer_info) - def commit_all(self, msg, author_info=None, edit=False): + def commit_all(self, msg, author_info=None, edit=False, committer_info=None): """ Commit all changes to the repository @param msg: commit message @type msg: C{str} @param author_info: authorship information @type author_info: L{GitModifier} + @param committer_info: committer information + @type committer_info: L{GitModifier} """ args = GitArgs('-a') args.add_true(edit, '--edit') - self._commit(msg=msg, args=args.args, author_info=author_info) + self._commit(msg=msg, args=args.args, author_info=author_info, + committer_info=committer_info) - def commit_files(self, files, msg, author_info=None): + def commit_files(self, files, msg, author_info=None, committer_info=None): """ Commit the given files to the repository @@ -1491,10 +1500,13 @@ def commit_files(self, files, msg, author_info=None): @type msg: C{str} @param author_info: authorship information @type author_info: L{GitModifier} + @param committer_info: committer information + @type committer_info: L{GitModifier} """ if isinstance(files, str): files = [files] - self._commit(msg=msg, args=files, author_info=author_info) + self._commit(msg=msg, args=files, author_info=author_info, + committer_info=committer_info) def commit_dir(self, unpack_dir, msg, branch, other_parents=None, author={}, committer={}, create_missing_branch=False):