mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-09 23:10:24 +01:00
pygit/dulwich: implement create branch (#5497)
* pygit: implement create branch * dulwich: implement create branch
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user