Package org.kohsuke.github
Class GHBranch
- java.lang.Object
-
- org.kohsuke.github.GHBranch
-
public class GHBranch extends Object
A branch in a repository.- Author:
- Yusuke Kokubo
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGHBranch.CommitThe type Commit.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voiddisableProtection()Disables branch protection and allows anyone with push access to push changes.GHBranchProtectionBuilderenableProtection()Enables branch protection to control what commit statuses are required to push.voidenableProtection(EnforcementLevel level, Collection<String> contexts)Deprecated.StringgetName()Gets name.GHRepositorygetOwner()Gets owner.GHBranchProtectiongetProtection()Gets protection.URLgetProtectionUrl()Gets protection url.GitHubgetRoot()Deprecated.For access to theGitHubinstance, use a local copy instead of pulling it out of objects.StringgetSHA1()Gets sha 1.booleanisProtected()Is protected boolean.GHCommitmerge(String head, String commitMessage)Merge a ref into this branch.GHCommitmerge(GHBranch headBranch, String commitMessage)Merge a branch into this branch.StringtoString()To string.
-
-
-
Method Detail
-
getOwner
public GHRepository getOwner()
Gets owner.- Returns:
- the repository that this branch is in.
-
getName
public String getName()
Gets name.- Returns:
- the name
-
isProtected
@Preview(LUKE_CAGE) public boolean isProtected()
Is protected boolean.- Returns:
- true if the push to this branch is restricted via branch protection.
-
getProtectionUrl
@Preview(LUKE_CAGE) public URL getProtectionUrl()
Gets protection url.- Returns:
- API URL that deals with the protection of this branch.
-
getProtection
@Preview(LUKE_CAGE) public GHBranchProtection getProtection() throws IOException
Gets protection.- Returns:
- the protection
- Throws:
IOException- the io exception
-
getSHA1
public String getSHA1()
Gets sha 1.- Returns:
- The SHA1 of the commit that this branch currently points to.
-
disableProtection
public void disableProtection() throws IOExceptionDisables branch protection and allows anyone with push access to push changes.- Throws:
IOException- if disabling protection fails
-
enableProtection
@Preview(LUKE_CAGE) public GHBranchProtectionBuilder enableProtection()
Enables branch protection to control what commit statuses are required to push.- Returns:
- GHBranchProtectionBuilder for enabling protection
- See Also:
GHCommitStatus#getContext()
-
enableProtection
@Deprecated public void enableProtection(EnforcementLevel level, Collection<String> contexts) throws IOException
Deprecated.Enable protection.- Parameters:
level- the levelcontexts- the contexts- Throws:
IOException- the io exception
-
merge
@CheckForNull public GHCommit merge(GHBranch headBranch, String commitMessage) throws IOException
Merge a branch into this branch.- Parameters:
headBranch- the branch whose head will be mergedcommitMessage- the commit message- Returns:
- the merge
GHCommitcreated, ornullif the base already contains the head (nothing to merge). - Throws:
IOException- if merging fails
-
merge
@CheckForNull public GHCommit merge(String head, String commitMessage) throws IOException
Merge a ref into this branch.- Parameters:
head- the ref name that will be merged into this branch. Follows the usual ref naming rules, could be a branch name, tag, or commit sha.commitMessage- the commit message- Returns:
- the merge
GHCommitcreated, ornullif the base already contains the head (nothing to merge). - Throws:
IOException- if merging fails
-
toString
public String toString()
To string.
-
getRoot
@Deprecated public GitHub getRoot()
Deprecated.For access to theGitHubinstance, use a local copy instead of pulling it out of objects.Get the rootGitHubinstance for this object.- Returns:
- the root
GitHubinstance
-
-