refs #2506 don't create branch if we're already on it
parent
175e6ece0d
commit
a10d1b10cb
|
@ -86,8 +86,11 @@ def commit_image(disk_num, partition_num, repository, branch, options, msg):
|
|||
|
||||
try:
|
||||
if branch:
|
||||
if not og_git.create_branch(device = device, name = branch):
|
||||
sys.exit(SystemLib.ogRaiseError([], ogGlobals.OG_ERR_FORMAT, f"Failed to create branch"))
|
||||
if og_git.get_current_branch(device = device) == branch:
|
||||
SystemLib.ogEcho(["command"], "info", "Branch same as active branch, not creating one.")
|
||||
else:
|
||||
if not og_git.create_branch(device = device, name = branch):
|
||||
sys.exit(SystemLib.ogRaiseError([], ogGlobals.OG_ERR_FORMAT, f"Failed to create branch"))
|
||||
|
||||
og_git.commit(device = device, message = msg)
|
||||
og_git.push(device = device, force = force_push)
|
||||
|
|
|
@ -1626,6 +1626,23 @@ class OpengnsysGitLibrary:
|
|||
# Restaurar cosas modificadas para git
|
||||
self._restore_metadata(path, destructive_only=True)
|
||||
|
||||
def get_current_branch(self, path = None, device = None):
|
||||
"""Returns the current active branch
|
||||
|
||||
Args:
|
||||
path (string, optional): Mountpoint
|
||||
device (string, optional): Device. Either mountpoint or device must be provided.
|
||||
|
||||
Returns:
|
||||
string: Branch name
|
||||
"""
|
||||
if path is None:
|
||||
path = self.fs.ensure_mounted(device)
|
||||
|
||||
repo = git.Repo(path)
|
||||
return repo.active_branch.name
|
||||
|
||||
|
||||
def create_branch(self, path = None, device = None, name = ""):
|
||||
if path is None:
|
||||
path = self.fs.ensure_mounted(device)
|
||||
|
|
Loading…
Reference in New Issue