Skip to content
Snippets Groups Projects
Commit c415a922 authored by Florian Heck's avatar Florian Heck
Browse files

added docs

parent d708d439
No related branches found
No related tags found
No related merge requests found
......@@ -11,6 +11,11 @@ public class Branch extends Reference {
super(repo, name);
}
/**
* Checks this branch out, and tries to pull changes on this current branch.
*
* @return true if the pull was successful
*/
public Boolean pull() {
if (!repo.checkout(this)) {
return false;
......@@ -29,11 +34,20 @@ public class Branch extends Reference {
return fetch.map(toBoolean).orElse(false);
}
/**
* Returns the id of the {@link Commit} this reference is currently pointing to.
*
* @return the id of the {@link Commit} under this branch
*/
@Override
public String getId() {
return repo.toHash(id).orElse(id);
}
/**
* Reruns the branch name
* @return the branch name
*/
public String getName() {
return id;
}
......
......@@ -25,10 +25,10 @@ public abstract class Reference {
}
/**
* Optionally returns the merge base for <code>this</code> and <code>other</code>. The <code>other</code> commit
* must be part of the same {@link Repository} this {@link Commit} is.
* Optionally returns the merge base for <code>this</code> and <code>other</code>. The <code>other</code> reference
* must be part of the same {@link Repository} this {@link Reference} is.
*
* @param other the other {@link Commit}
* @param other the other {@link Reference}
* @return the merge base or an empty {@link Optional} if there is no merge base or an exception occurred
*/
public Optional<Commit> getMergeBase(Reference other) {
......@@ -60,6 +60,13 @@ public abstract class Reference {
return mergeBase.map(toCommit);
}
/**
* Performs a merge of <code>this</code> and <code>other</code>. <code>Other</code> must be part of the same
* {@link Repository} this {@link Reference} is.
*
* @param other the {@link Reference} to merge
* @return <code>false</code>, if the merge failed, or contains conflicts.
*/
public Boolean merge(Reference other) {
Optional<ProcessExecutor.ExecRes> mergeBase = git.exec(repo.getDir(), "merge", "-n", "-q", other.getId());
Function<ProcessExecutor.ExecRes, Boolean> toBoolean = res -> {
......
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