aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2017-05-26 16:30:29 +0200
committerGuido Günther <agx@sigxcpu.org>2017-05-26 16:30:29 +0200
commit0372be09cf6f68c4ade2e74b66cac8251d005a66 (patch)
treea8936b3e012d42a3b1907e3b9440b292e6838b0e
parentd488ac4fae3683c059de9ef7d7675150acdc2ef1 (diff)
GitRepository: add set_config
-rw-r--r--gbp/git/repository.py7
-rw-r--r--tests/doctests/test_GitRepository.py14
2 files changed, 21 insertions, 0 deletions
diff --git a/gbp/git/repository.py b/gbp/git/repository.py
index 2cf4879..991b0fa 100644
--- a/gbp/git/repository.py
+++ b/gbp/git/repository.py
@@ -1110,6 +1110,13 @@ class GitRepository(object):
raise KeyError
return value[0][:-1] # first line with \n ending removed
+ def set_config(self, name, value):
+ """
+ Set a git config value in this repository
+ """
+ args = GitArgs(name, value)
+ self._git_command("config", args.args)
+
def set_user_name(self, name):
"""
Sets the full name to use for git commits.
diff --git a/tests/doctests/test_GitRepository.py b/tests/doctests/test_GitRepository.py
index 420ba1c..a11211d 100644
--- a/tests/doctests/test_GitRepository.py
+++ b/tests/doctests/test_GitRepository.py
@@ -1039,6 +1039,20 @@ def test_set_user_name_and_email():
"""
+def test_set_config_and_get_config():
+ r"""
+ Methods tested:
+ - L{gbp.git.GitRepository.set_config}
+ - L{gbp.git.GitRepository.get_config}
+
+ >>> import gbp.git
+ >>> repo = gbp.git.GitRepository(dirs['repo'])
+ >>> repo.set_config("user.email", "foo@example.com")
+ >>> repo.get_config("user.email")
+ 'foo@example.com'
+ """
+
+
def test_git_dir():
"""
Properties tested: