Check if branch exists locally or upstream before branching out

This commit is contained in:
Waqar Ahmed
2021-08-16 13:24:55 +05:00
parent d111089179
commit 80fca3d4ef
3 changed files with 23 additions and 2 deletions

View File

@@ -5,7 +5,8 @@ import shutil
from scale_build.config import BRANCH_OVERRIDES, TRY_BRANCH_OVERRIDE
from scale_build.exceptions import CallError
from scale_build.utils.git_utils import (
branch_exists_in_repository, create_branch, retrieve_git_remote_and_sha, retrieve_git_branch, update_git_manifest
branch_checked_out_locally, branch_exists_in_repository, create_branch,
retrieve_git_remote_and_sha, retrieve_git_branch, update_git_manifest
)
from scale_build.utils.logger import LoggingContext
from scale_build.utils.paths import GIT_LOG_PATH
@@ -20,6 +21,12 @@ class GitPackageMixin:
def branch_out(self, new_branch_name, base_branch_override=None):
create_branch(self.source_path, base_branch_override or self.branch, new_branch_name)
def branch_exists_in_remote(self, branch):
return branch_exists_in_repository(self.origin, branch)
def branch_checked_out_locally(self, branch):
return branch_checked_out_locally(self.source_path, branch)
def retrieve_current_remote_origin_and_sha(self):
if self.exists:
return retrieve_git_remote_and_sha(self.source_path)