update branch & change base on PRs

This commit is contained in:
Tadas Giniotis
2020-08-12 01:31:51 +03:00
parent fc38dba59a
commit ceb2d35f9f
2 changed files with 43 additions and 0 deletions

View File

@@ -37,6 +37,7 @@ import java.util.Objects;
import javax.annotation.CheckForNull;
import static org.kohsuke.github.Previews.LYDIAN;
import static org.kohsuke.github.Previews.SHADOW_CAT;
/**
@@ -565,6 +566,41 @@ public class GHPullRequest extends GHIssue implements Refreshable {
.send();
}
/**
* Set the base branch on the pull request
*
* @param newBaseBranch
* the name of the new base branch
* @throws IOException
* the io exception
* @return the updated pull request
*/
public GHPullRequest setBaseBranch(String newBaseBranch) throws IOException {
return root.createRequest()
.method("PATCH")
.with("base", newBaseBranch)
.withUrlPath(getApiRoute())
.fetch(GHPullRequest.class)
.wrapUp(root);
}
/**
* Updates the branch. The same as pressing the button in the web GUI.
*
* @throws IOException
* the io exception
*/
@Preview
@Deprecated
public void updateBranch() throws IOException {
root.createRequest()
.withPreview(LYDIAN)
.method("PUT")
.with("expected_head_sha", head.getSha())
.withUrlPath(getApiRoute() + "/update-branch")
.send();
}
/**
* Merge this pull request.
* <p>

View File

@@ -44,6 +44,13 @@ class Previews {
*/
static final String INERTIA = "application/vnd.github.inertia-preview+json";
/**
* Update a pull request branch
*
* @see <a href="https://developer.github.com/v3/previews/#update-a-pull-request-branch">GitHub API Previews</a>
*/
static final String LYDIAN = "application/vnd.github.lydian-preview+json";
/**
* Require multiple approving reviews
*