Skip to content
Snippets Groups Projects
Commit 7c73b56d authored by Georg Seibt's avatar Georg Seibt :nerd:
Browse files

checkout and doc formatting

parent df74e6ed
No related branches found
No related tags found
No related merge requests found
......@@ -56,6 +56,35 @@ public class Repository {
this.commits = new HashMap<>();
}
/**
* Performs a checkout of the given {@link Commit}.
*
* @param c
* the {@link Commit} to checkout
* @return whether the checkout was successful
* @see <a href=https://git-scm.com/docs/git-checkout>git-checkout</a>
*/
public boolean checkout(Commit c) {
if (!commits.containsValue(c)) {
LOG.warning(() -> String.format("Checkout failed. %s is not part of %s.", c, this));
return false;
}
Optional<ExecRes> checkout = git.exec(dir, "checkout", c.getId());
Function<ExecRes, Boolean> toBoolean = res -> {
boolean failed = git.failed(res);
if (failed) {
LOG.warning(() -> String.format("Checkout of %s failed.", c));
}
return failed;
};
return checkout.map(toBoolean).orElse(false);
}
/**
* Returns the merge commits in this repository.
*
......@@ -85,7 +114,8 @@ public class Repository {
* Returns a {@link Commit} for the given ID. The caller must ensure that the ID is a full SHA1 hash of a
* commit that exists in this repository.
*
* @param id the ID for the {@link Commit}
* @param id
* the ID for the {@link Commit}
* @return the {@link Commit}
*/
Commit getCommitUnchecked(String id) {
......@@ -96,7 +126,8 @@ public class Repository {
* Returns a {@link Commit} for the given ID. If the given ID does not designate a commit that exists in this
* {@link Repository} an empty {@link Optional} will be returned. The ID will be resolved to a full SHA1 hash.
*
* @param id the ID of the commit
* @param id
* the ID of the commit
* @return the {@link Commit} or an empty {@link Optional} if the ID is invalid or an exception occurs
*/
public Optional<Commit> getCommit(String id) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment