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

move checkAncestry method up

parent fa236ada
No related branches found
No related tags found
No related merge requests found
...@@ -43,6 +43,19 @@ public class Commit extends Reference { ...@@ -43,6 +43,19 @@ public class Commit extends Reference {
super(repo, id); super(repo, id);
} }
/**
* Checks if the given {@link Commit} is an ancestor of this commit.
*
* @param ancestor
* the {@link Commit} to check
* @return optionally <code>true</code>, if the given commit is in the history before this commit,
* <code>false</code>, if not and an {@link Optional#EMPTY empty optional}, if an error occurred.
*/
public Optional<Boolean> checkAncestry(Commit ancestor) {
return git.exec(repo.getDir(), " merge-base", "--is-ancestor", ancestor.getId(), id).map(execRes ->
execRes.exitCode == 0 ? Boolean.TRUE : execRes.exitCode == 1 ? Boolean.FALSE : null);
}
/** /**
* Returns the author of this commit. * Returns the author of this commit.
* *
...@@ -246,17 +259,4 @@ public class Commit extends Reference { ...@@ -246,17 +259,4 @@ public class Commit extends Reference {
} }
}); });
} }
/**
* Checks if the given {@link Commit} is an ancestor of this commit.
*
* @param ancestor
* the {@link Commit} to check
* @return optionally <code>true</code>, if the given commit is in the history before this commit,
* <code>false</code>, if not and an {@link Optional#EMPTY empty optional}, if an error occurred.
*/
public Optional<Boolean> checkAncestry(Commit ancestor) {
return git.exec(repo.getDir(), " merge-base", "--is-ancestor", ancestor.getId(), id).map(execRes ->
execRes.exitCode == 0 ? Boolean.TRUE : execRes.exitCode == 1 ? Boolean.FALSE : null);
}
} }
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