Class GitRebaseCommandParameters

java.lang.Object
com.atlassian.bitbucket.util.BuilderSupport
com.atlassian.bitbucket.scm.AbstractCommandParameters
com.atlassian.bitbucket.scm.git.command.GitRebaseCommandParameters

public class GitRebaseCommandParameters extends com.atlassian.bitbucket.scm.AbstractCommandParameters
Parameters to perform a git rebase operation for a given branch, to recreate its unique commits based on a given upstream.
Since:
5.5
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     
  • Field Summary

    Fields inherited from class com.atlassian.bitbucket.util.BuilderSupport

    NOT_BLANK
  • Method Summary

    Modifier and Type
    Method
    Description
    com.atlassian.bitbucket.repository.Branch
    Retrieves the branch which should be rebased.
    com.atlassian.bitbucket.user.ApplicationUser
     
    Retrieves the commit to compare the branch against and to serve as the starting point for the rebased commits.
    Optional<com.atlassian.bitbucket.repository.Repository>
    Retrieves the repository containing the upstream to use when rebasing, if it is not in the branch's repository.
    boolean
    Retrieves a flag indicating whether a rebase is required to produce at least one commit, or whether it is allowed to reset the branch to the upstream commit as-is.
    boolean
     

    Methods inherited from class com.atlassian.bitbucket.util.BuilderSupport

    addIf, addIf, addIf, addIf, addIf, addIf, checkNotBlank, requireNonBlank

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getBranch

      @Nonnull public com.atlassian.bitbucket.repository.Branch getBranch()
      Retrieves the branch which should be rebased. Commits unique to this branch, compared to upstream, will be recreated as descendants of the upstream commit.

      git rebase allows starting from a specific commit (detached HEAD, not just branches, but performing a rebase via this API intentionally does not. The rebase is performed in a temporary work tree, since git rebase cannot be run in bare repositories, and a specific branch to update is required in order to fetch the rebased commits back into the bare repository.

      Returns:
      the branch to rebase
    • getCommitter

      @Nonnull public com.atlassian.bitbucket.user.ApplicationUser getCommitter()
      Returns:
      the user performing the rebase
    • getUpstream

      @Nonnull public String getUpstream()
      Retrieves the commit to compare the branch against and to serve as the starting point for the rebased commits. This value must be specified as a full 40-character SHA-1. using a ref name is not supported.
      Returns:
      the upstream commit to rebase the branch's unique commits against
    • getUpstreamRepository

      @Nonnull public Optional<com.atlassian.bitbucket.repository.Repository> getUpstreamRepository()
      Retrieves the repository containing the upstream to use when rebasing, if it is not in the branch's repository.
      Returns:
      the upstream repository, which may be empty() if the branch and the desired upstream are in the same repository
    • isCommitRequired

      public boolean isCommitRequired()
      Retrieves a flag indicating whether a rebase is required to produce at least one commit, or whether it is allowed to reset the branch to the upstream commit as-is.

      Regardless of the number of unique commits on the branch, if all of their individual changes have already been applied in a compatible way on the upstream (such that no conflicts arise), the rebase may discard all of the branch's commits. In some cases that may be desirable, and in some it may not.

      Returns:
      true if the rebase should fail if all of the branch's commits are discarded; otherwise, false to allow the branch to be reset to the upstream commit
    • isDryRun

      public boolean isDryRun()
      Returns:
      true to perform the rebase without updating the branch; otherwise, false to apply the rebase and update the branch