From 16a2cd36e60a9241aeff01e923c0b77f7913ce7c Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Thu, 12 Jan 2012 15:22:51 +0200 Subject: GitRepository: add rename_branch() method --- gbp/git/repository.py | 10 ++++++++++ tests/test_GitRepository.py | 17 +++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/gbp/git/repository.py b/gbp/git/repository.py index d6b9874..3c79896 100644 --- a/gbp/git/repository.py +++ b/gbp/git/repository.py @@ -178,6 +178,16 @@ class GitRepository(object): return self.rev_parse('HEAD') #{ Branches and Merging + def rename_branch(self, branch, newbranch): + """ + Rename branch + + @param branch: name of the branch to be renamed + @param newbranch: new name of the branch + """ + args = GitArgs("-m", branch, newbranch) + self._git_command("branch", args.args) + def create_branch(self, branch, rev=None): """ Create a new branch diff --git a/tests/test_GitRepository.py b/tests/test_GitRepository.py index 23f4f99..ada3a01 100644 --- a/tests/test_GitRepository.py +++ b/tests/test_GitRepository.py @@ -158,6 +158,23 @@ def test_set_branch(): """ +def test_rename_branch(): + """ + Create branch named I{baz}, rename it to I{bax} and finally delete it + + Methods tested: + - L{gbp.git.GitRepository.create_branch} + - L{gbp.git.GitRepository.rename_branch} + - L{gbp.git.GitRepository.delete_branch} + + >>> import gbp.git + >>> repo = gbp.git.GitRepository(repo_dir) + >>> repo.create_branch("baz") + >>> repo.rename_branch("baz", "bax") + >>> repo.delete_branch("bax") + """ + + def test_tag(): """ Create a tag named I{tag} and check it's existance -- cgit v1.2.3