def unique_branch_name(self, prefix): """Get an unused branch name in the local tree :param prefix: Prefix to use at the start of the branch name""" branches = [ref[len("refs/heads/"):] for sha1, ref in self.list_refs() if ref.startswith("refs/heads/")] return get_unique_name(branches, prefix)
def create(self, state): remote_branch = "sync_%s" % state.commit.sha1 branches = [ ref[len("refs/heads/"):] for sha1, ref in state.sync_tree.list_remote(state.gh_repo.url) if ref.startswith("refs/heads") ] state.remote_branch = get_unique_name(branches, remote_branch)