def __init__(self, local_git_repo, disable_lfs=False, promote_retry_count=3): self.local_git_repo = local_git_repo self.git = utils.get_git_scm(local_git_repo, config_init=True) self.promote_retry_count = promote_retry_count if disable_lfs: # Local command, not catching exceptions logger.info("Disabling LFS hooks...") self.git.runRawCommand(['lfs', 'uninstall'])
def main(local_repo_path, repo_url, commit_hash): if not os.path.isdir(local_repo_path): os.makedirs(local_repo_path) try: git = utils.get_git_scm(local_repo_path, remoterepo=repo_url, config_init=False) logger.info("Cloning {}...".format(repo_url)) git.clone() logger.info("Checking out repository revision {}...".format(commit_hash)) git.gotoRevision(commit_hash) except ScmError, e: logger.error("The following unexpected exception occurred while cloning the repository:\n{}".format(e.msg)) raise PassThroughException()
def main(local_git_repo, model_update_commit_msg, smi_files_update_commit_msg): try: git = utils.get_git_scm(local_git_repo) git.setDebug(True) should_push_changes = False # Required for passwordless pushes over SSH! git.runRawCommand(['lfs', 'uninstall']) git.addFile(MODEL_FILE_PATH) if len(git.status("modified")) > 0: git.commit(model_update_commit_msg) should_push_changes = True else: logger.info( "No changes detected to file {}.".format(MODEL_FILE_PATH)) git.addFile(r"data/SMI/\*.ini") git.addFile(r"data/SMI/\*.dat") if len(git.status("modified")) > 0: git.commit(smi_files_update_commit_msg) should_push_changes = True else: logger.info("No changes detected to SMI files.") if should_push_changes: push_success = False for i in range(0, PUSH_RETRY): try: logger.info( "Pushing model file and SMI file updates to origin attempt {}/{}" .format((i + 1), PUSH_RETRY)) # We expect no merge conflicts against the file this process updates. git.updateAndMerge() git.push() push_success = True break except ScmError as e: logger.error("SCM exception caught: {}".format(e.msg)) if not push_success: raise PassThroughException() logger.info( "Successfully pushed updated files to origin. Exiting.") except ScmError as e: logger.error("SCM exception caught: {}".format(e)) raise e