def inspect_branch(self, repo_name, branch_name):
     """
     Inspects a branch. Returns a `BranchInfo` object.
     """
     branch = proto.Branch(repo=proto.Repo(name=repo_name), name=branch_name)
     req = proto.InspectBranchRequest(branch=branch)
     return self.stub.InspectBranch(req, metadata=self.metadata)
Example #2
0
 def delete_branch(self, repo_name, branch_name, force=None):
     """
     Deletes a branch, but leaves the commits themselves intact. In other
     words, those commits can still be accessed via commit IDs and other
     branches they happen to be on.
     Params:
     * repo_name: A string specifying the repo name.
     * branch_name: A string specifying the name of the branch to delete.
     * force: A bool specifying whether to force the branch deletion.
     """
     branch = proto.Branch(repo=proto.Repo(name=repo_name),
                           name=branch_name)
     req = proto.DeleteBranchRequest(branch=branch, force=force)
     self.stub.DeleteBranch(req, metadata=self.metadata)
    def create_branch(self, repo_name, branch_name, commit=None, provenance=None):
        """
        Creates a new branch.

        Params:
        * repo_name: A string specifying the name of the repo.
        * branch_name: A string specifying the new branch name.
        * commit: An optional tuple, string, or `Commit` object representing
        the head commit of the branch.
        * provenance: An optional iterable of `Branch` objects representing
        the branch provenance.
        """
        req = proto.CreateBranchRequest(
            branch=proto.Branch(repo=proto.Repo(name=repo_name), name=branch_name),
            head=commit_from(commit) if commit is not None else None,
            provenance=provenance,
        )
        self.stub.CreateBranch(req, metadata=self.metadata)