Skip to content
Snippets Groups Projects
Commit 3c28c521 authored by Jonas Schrottenbaum's avatar Jonas Schrottenbaum
Browse files

Added method to check if a Reference contains a certain file.

parent 202b5b5d
No related branches found
No related tags found
1 merge request!4Add hasFile(Commit) Method
package de.uni_passau.fim.gitwrapper;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
......@@ -126,6 +127,18 @@ public abstract class Reference {
return revList.map(toParentsList);
}
/**
* Checks if this {@link Commit} contains the specified file.
*
* @param file The file to check the {@link Commit} for existence.
* @return {@code True} if the {@link Commit} contains the file, {@code False} otherwise.
*/
public boolean hasFile(Path file) {
Optional<ProcessExecutor.ExecRes> result = git.exec(repo.getDir(), "cat-file",
"-e", id + ":" + file);
return result.get().succeeded();
}
@Override
public final boolean equals(Object o) {
if (this == o) {
......
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