| 463 | # Branch-related methods |
| 464 | |
| 465 | def create_branch(self, name, head): |
| 466 | if self.lookup_branch(name): |
| 467 | raise GlError( |
| 468 | 'Branch {0} already exists in remote repository {1}'.format( |
| 469 | name, self.name)) |
| 470 | # Push won't let us push the creation of a new branch from a SHA. So we |
| 471 | # create a temporary local ref, make it point to the commit, and do the |
| 472 | # push |
| 473 | tmp_b = self.gl_repo.create_branch('gl_tmp_ref', head) |
| 474 | try: |
| 475 | git.push(self.name, '{0}:{1}'.format(tmp_b, name)) |
| 476 | return self.lookup_branch(name) |
| 477 | except ErrorReturnCode as e: |
| 478 | raise GlError(stderr(e)) |
| 479 | finally: |
| 480 | tmp_b.delete() |
| 481 | |
| 482 | def listall_branches(self): |
| 483 | """Return a list with the names of all the branches in this repository. |