pygit/dulwich: implement create branch (#5497)

* pygit: implement create branch

* dulwich: implement create branch
This commit is contained in:
Peter Rowlands (변기호)
2021-02-19 17:18:15 +09:00
committed by GitHub
parent 9cb8187cb3
commit 7d13d24a1f
2 changed files with 13 additions and 2 deletions
+6 -1
View File
@@ -200,7 +200,12 @@ class DulwichBackend(BaseGitBackend): # pylint:disable=abstract-method
raise NotImplementedError
def branch(self, branch: str):
raise NotImplementedError
from dulwich.porcelain import Error, branch_create
try:
branch_create(self.root_dir, branch)
except Error as exc:
raise SCMError(f"Failed to create branch '{branch}'") from exc
def tag(self, tag: str):
raise NotImplementedError
+7 -1
View File
@@ -116,7 +116,13 @@ class Pygit2Backend(BaseGitBackend): # pylint:disable=abstract-method
raise NotImplementedError
def branch(self, branch: str):
raise NotImplementedError
from pygit2 import GitError
try:
commit = self.repo[self.repo.head.target]
self.repo.create_branch(branch, commit)
except GitError as exc:
raise SCMError(f"Failed to create branch '{branch}'") from exc
def tag(self, tag: str):
raise NotImplementedError