From a32012a0fa11447d583e017cc8c79fbbc8c9d59e Mon Sep 17 00:00:00 2001 From: Georg Seibt <seibt@fim.uni-passau.de> Date: Fri, 21 Oct 2016 15:23:25 +0200 Subject: [PATCH] use the actual Commit object instead of its id in the Status, small doc fixes --- .../fim/seibt/gitwrapper/repo/Status.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/de/uni_passau/fim/seibt/gitwrapper/repo/Status.java b/src/de/uni_passau/fim/seibt/gitwrapper/repo/Status.java index 155adfb..790412f 100644 --- a/src/de/uni_passau/fim/seibt/gitwrapper/repo/Status.java +++ b/src/de/uni_passau/fim/seibt/gitwrapper/repo/Status.java @@ -1,5 +1,6 @@ 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)); } } -- GitLab