From 2faf600a695a8822e8c00a04b946b78dc4bafcba Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Mon, 21 Nov 2011 23:11:27 +0100 Subject: Use GitArgs in GitRepository.{create,delete}_branch() --- gbp/git/__init__.py | 14 +++++++------- tests/test_GitRepository.py | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/gbp/git/__init__.py b/gbp/git/__init__.py index a5934a6..96e79b1 100644 --- a/gbp/git/__init__.py +++ b/gbp/git/__init__.py @@ -190,10 +190,9 @@ class GitRepository(object): If rev is None the branch starts form the current HEAD. """ - args = [ branch ] - args += [ rev ] if rev else [] - - self._git_command("branch", args) + args = GitArgs(branch) + args.add_true(rev, rev) + self._git_command("branch", args.args) def delete_branch(self, branch, remote=False): """ @@ -204,11 +203,12 @@ class GitRepository(object): @param remote: delete a remote branch @param remote: C{bool} """ - args = [ "-D" ] - args += [ "-r" ] if remote else [] + args = GitArgs('-D') + args.add_true(remote, '-r') + args.add(branch) if self.branch != branch: - self._git_command("branch", args + [branch]) + self._git_command("branch", args.args) else: raise GitRepositoryError, "Can't delete the branch you're on" diff --git a/tests/test_GitRepository.py b/tests/test_GitRepository.py index 235c758..6bf40ee 100644 --- a/tests/test_GitRepository.py +++ b/tests/test_GitRepository.py @@ -116,6 +116,20 @@ def test_create_branch(): >>> repo.create_branch("foo") """ +def test_delete_branch(): + """ + Create a branch named I{foo2} and delete it + + Methods tested: + - L{gbp.git.GitRepository.create_branch} + - L{gbp.git.GitRepository.delete_branch} + + >>> import gbp.git, shutil + >>> repo = gbp.git.GitRepository(repo_dir) + >>> repo.create_branch("bar") + >>> repo.delete_branch("bar") + """ + def test_set_branch(): """ -- cgit v1.2.3