(user: str, repo: str, sha: str, branch_name: str)
| 136 | |
| 137 | |
| 138 | def update_branch(user: str, repo: str, sha: str, branch_name: str) -> None: |
| 139 | git(["fetch", "origin", sha]) |
| 140 | git(["reset", "--hard", "FETCH_HEAD"]) |
| 141 | try: |
| 142 | git(["branch", "-D", branch_name]) |
| 143 | except RuntimeError: |
| 144 | # Ignore failures (i.e. the branch did not exist in the first place) |
| 145 | pass |
| 146 | git(["checkout", "-b", branch_name]) |
| 147 | |
| 148 | # Create and push the branch |
| 149 | git(["push", "origin", "--force", branch_name]) |
| 150 | print(f"Pushed branch {branch_name} with commit {sha}") |
| 151 | |
| 152 | |
| 153 | if __name__ == "__main__": |
no test coverage detected
searching dependent graphs…