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

use the actual Commit object instead of its id in the Status, small doc fixes

parent e4851a80
No related branches found
No related tags found
No related merge requests found
package de.uni_passau.fim.seibt.gitwrapper.repo;
import java.io.StringWriter;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collections;
......@@ -21,10 +22,10 @@ public class Status {
/**
* The commit, this {@link Status} is based on.
*/
public final String id;
public final Commit commit;
/**
* A map of files which were changed since the last commit (with id {@link #id}) and their status codes.
* A map of files which were changed since the last {@link #commit} and their status codes.
*/
public final Map<Path, String> changed;
......@@ -34,18 +35,20 @@ public class Status {
public final Map<Path, String> unmerged;
/**
* @param id the commit id
* Constructs a new {@link Status}.
*
* @param commit the current HEAD {@link Commit} at the time this {@link Status} is constructed
* @param changed a map of changed files and heir status codes
* @param unmerged a map of unmerged files an their status code.
*/
private Status(String id, Map<Path, String> changed, Map<Path, String> unmerged) {
this.id = id;
private Status(Commit commit, Map<Path, String> changed, Map<Path, String> unmerged) {
this.commit = commit;
this.changed = Collections.unmodifiableMap(changed);
this.unmerged = Collections.unmodifiableMap(unmerged);
}
/**
* Checks, if <code>this</code> represents a clean repository.
* Returns whether this {@link Status} represents a clean repository.
*
* @return <code>true</code>, if the repository state is clean and has uncommitted changes.
*/
......@@ -54,7 +57,7 @@ public class Status {
}
/**
* Checks, if <code>this</code> has unmerged files.
* Returns whether this {@link Status} has unmerged files.
*
* @return <code>true</code>, if there are unmerged files
*/
......@@ -66,7 +69,7 @@ public class Status {
public String toString() {
String out = "";
if (isClean()) {
out = "Clean working directory on commit " + id + "\n";
out = "Clean working directory on commit " + commit + "\n";
} else {
if (!unmerged.isEmpty()) {
out = "Unmerged files:";
......@@ -105,6 +108,6 @@ public class Status {
}
}
return repo.getCurrentHEAD().map(head -> new Status(head.id, changed, unmerged));
return repo.getCurrentHEAD().map(head -> new Status(head, changed, unmerged));
}
}
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