def check_repo() -> None: # check we are on a master branch that is in sync repo = Repo(".") assert_step((repo.active_branch.name == 'master')) GitUtilities.check_no_uncommitted_changes(repo) assert_step(len( list(repo.iter_commits('master@{u}..master'))) == 0, f"there are un-pushed changes in approvaltests") GitUtilities.pull_active_branch_origin(".")
def check_pre_conditions_for_main_repo(self) -> None: repo = Repo(self.details.locations.main_project_dir) assert_step(not repo.bare) GitUtilities.check_branch_name(repo, 'master') GitUtilities.check_no_uncommitted_changes(repo) # From https://stackoverflow.com/questions/15849640/how-to-get-count-of-unpublished-commit-with-gitpython assert_step(len( list(repo.iter_commits('master@{u}..master'))) == 0, f"there are un-pushed changes in {self.details.project_details.github_project_name}")
def check_pre_conditions_for_publish(self) -> None: if self.details.push_to_production: repo = Repo(release_constants.main_project_dir) assert_step(not repo.bare) assert_step((repo.active_branch.name == 'master')) GitUtilities.check_no_uncommitted_changes(repo) # From https://stackoverflow.com/questions/15849640/how-to-get-count-of-unpublished-commit-with-gitpython assert_step(len( list(repo.iter_commits('master@{u}..master'))) == 0, "there are un-pushed changes in ApprovalTests.cpp") run(["open", "https://github.com/approvals/ApprovalTests.cpp/commits/master"]) check_step("the builds are passing") run(["open", "https://github.com/approvals/ApprovalTests.cpp/blob/master/build/relnotes_x.y.z.md"]) run(["open", F"https://github.com/approvals/ApprovalTests.cpp/compare/{self.details.old_version.get_version_text()}...master"]) check_step("the release notes are ready") run(["open", "https://github.com/approvals/ApprovalTests.cpp/issues"]) check_step("any issues resolved in this release are closed") run(["open", "https://github.com/approvals/ApprovalTests.cpp/milestones"]) check_step("the milestone (if any) is up to date, including actual version number of release")
def check_no_uncommitted_changes(repo: Repo) -> None: assert_step(not repo.bare) # From https://stackoverflow.com/questions/31959425/how-to-get-staged-files-using-gitpython repo_name = GitUtilities.get_repo_name(repo) assert_step( len(repo.index.diff(None)) == 0, f"there are un-committed changes to {repo_name}") # Modified assert_step( len(repo.index.diff("HEAD")) == 0, f"there are staged changes to {repo_name}") # Staged
def check_pre_conditions_for_starter_project_repo(self) -> None: repo = Repo(self.details.locations.starter_project_dir) assert_step(not repo.bare) GitUtilities.check_branch_name(repo, 'master')
def publish_starter_project(details: ReleaseDetails) -> None: DeployStarterProjectRelease.commit_starter_project(details) DeployStarterProjectRelease.push_starter_project(details) assert_step(DeployStarterProjectRelease.check_starter_project_published(details), "the starter project is published")
def check_branch_name(repo: Repo, branch_name: str) -> None: repo_name = GitUtilities.get_repo_name(repo) assert_step((repo.active_branch.name == branch_name), f"the {repo_name} repo is not on branch {branch_name}")
def publish_starter_project(self) -> None: self.commit_starter_project() self.push_starter_project() assert_step(self.check_starter_project_published(), "the starter project is published")