From a7ded3f4e09c60c17ff697274b71a72db28e1288 Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Wed, 5 Feb 2014 16:11:42 +0200 Subject: [PATCH 1/4] GitRepository.commit_files: add committer_info argument For setting the committer name/email/date - similarly to author_info. Signed-off-by: Markus Lehtonen --- gbp/git/repository.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/gbp/git/repository.py b/gbp/git/repository.py index 6cc3cd9f..9f0704c6 100644 --- a/gbp/git/repository.py +++ b/gbp/git/repository.py @@ -1450,8 +1450,10 @@ 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): @@ -1481,7 +1483,7 @@ def commit_all(self, msg, author_info=None, edit=False): args.add_true(edit, '--edit') self._commit(msg=msg, args=args.args, author_info=author_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 +1493,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): From 81846791b89076c45e5fd2ae977baf3322657b62 Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Wed, 5 Feb 2014 16:11:42 +0200 Subject: [PATCH 2/4] GitRepository.commit_staged: add committer_info argument For setting the committer name/email/date - similarly to author_info. Signed-off-by: Markus Lehtonen --- gbp/git/repository.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gbp/git/repository.py b/gbp/git/repository.py index 9f0704c6..9a653197 100644 --- a/gbp/git/repository.py +++ b/gbp/git/repository.py @@ -1456,7 +1456,8 @@ def _commit(self, msg, args=[], author_info=None, committer_info=None): 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 @@ -1466,10 +1467,13 @@ 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): """ From 417eac6d370aa8608a0bc5b08005fc86c9e7c026 Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Tue, 23 Jan 2018 12:21:07 +0200 Subject: [PATCH 3/4] GitRepository.commit_all: add committer_info argument Signed-off-by: Markus Lehtonen --- gbp/git/repository.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gbp/git/repository.py b/gbp/git/repository.py index 9a653197..85de4fb1 100644 --- a/gbp/git/repository.py +++ b/gbp/git/repository.py @@ -1475,17 +1475,20 @@ def commit_staged(self, msg, author_info=None, edit=False, 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, committer_info=None): """ From 831aeaf707732afe1a898c8cf53f17123ddccc23 Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Tue, 23 Jan 2018 14:14:50 +0200 Subject: [PATCH 4/4] GitRepository: slightly change handling of extra_env arg No need to build 'env' arg for popen when extra_env is empty. In some methods an empty dict is used to indicate "no extra env". This commit does not affect the output/outcome of GitRepository operations, but, just makes the code a tiny bit sleeker. Signed-off-by: Markus Lehtonen --- gbp/git/repository.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gbp/git/repository.py b/gbp/git/repository.py index 85de4fb1..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