Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All the refs worth knowing: Implementation of ref updating and deleting. #117

Merged
merged 2 commits into from
Aug 30, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions src/main/java/org/kohsuke/github/GHRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,46 @@ public GHRef createRef(String name, String sha) throws IOException {
.with("ref", name).with("sha", sha).method("POST").to(getApiTailUrl("git/refs"), GHRef.class);
}

/**
* Updates a named ref, such as a tag, branch, etc.
*
* @param name
* The name of the fully qualified reference (ie: refs/heads/master).
* If it doesn't start with 'refs' and have at least two slashes, it will be rejected.
* @param sha
* The SHA1 value to set this reference to
*/
public GHRef updateRef(String name, String sha) throws IOException {
return updateRef(name, sha, false);
}

/**
* Updates a named ref, such as a tag, branch, etc.
*
* @param name
* The name of the fully qualified reference (ie: refs/heads/master).
* If it doesn't start with 'refs' and have at least two slashes, it will be rejected.
* @param sha
* The SHA1 value to set this reference to
* @param force
* Whether or not to force this ref update.
*/
public GHRef updateRef(String name, String sha, Boolean force) throws IOException {
return new Requester(root)
.with("sha", sha).with("force", force).method("PATCH").to(getApiTailUrl("git/" + name), GHRef.class);
}

/**
* Deletes a particular ref from the repository using the GitHub API.
*
* @param name
* The name of the fully qualified reference (ie: refs/heads/master).
* If it doesn't start with 'refs' and have at least two slashes, it will be rejected.
*/
public void deleteRef(String name) throws IOException {
new Requester(root).method("DELETE").to(getApiTailUrl("git/" + name));
}

/**
* @deprecated
* use {@link #listReleases()}
Expand Down