From 8da225022536ed8f87a9ff78832151b6ad7e4b1a Mon Sep 17 00:00:00 2001 From: Florian Heck <florian.heck@hotmail.de> Date: Tue, 18 Oct 2016 17:51:24 +0200 Subject: [PATCH] documentation for status --- .../fim/seibt/gitwrapper/repo/Status.java | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 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 8cb4112..d3c5382 100644 --- a/src/de/uni_passau/fim/seibt/gitwrapper/repo/Status.java +++ b/src/de/uni_passau/fim/seibt/gitwrapper/repo/Status.java @@ -8,20 +8,35 @@ import java.util.regex.Pattern; public class Status { private static final Pattern STATUS_ENTRY = Pattern.compile("(.?.) (?:.*? )?(.*?)\0"); - public final String head; + public final String id; public final Map<File, String> changed; public final Map<File, String> unmerged; - private Status(String head, Map<File, String> changed, Map<File, String> unmerged) { - this.head = head; + /** + * @param id the commit id + * @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<File, String> changed, Map<File, String> unmerged) { + this.id = id; this.changed = Collections.unmodifiableMap(changed); this.unmerged = Collections.unmodifiableMap(unmerged); } + /** + * Checks, if <code>this</code> represents a clean repository. + * + * @return <code>true</code>, if the repository state is clean and has uncommitted changes. + */ public boolean isClean() { return changed.isEmpty() && unmerged.isEmpty(); } + /** + * Checks, if <code>this</code> has unmerged files. + * + * @return <code>true</code>, if there are unmerged files + */ public boolean hasConflicts() { return !unmerged.isEmpty(); } @@ -30,7 +45,7 @@ public class Status { public String toString() { String out = ""; if (isClean()) { - out = "Clean working directory on commit " + head + "\n"; + out = "Clean working directory on commit " + id + "\n"; } else { if (!unmerged.isEmpty()) { out = "Unmerged files:"; @@ -47,6 +62,13 @@ public class Status { return out; } + /** + * Parses the output from git into a new object. + * + * @param repo the repo this status report is from + * @param gitOutput the status report from git + * @return a {@link Status} object, representing the status read from the git output + */ static Status parseStatus(Repository repo, String gitOutput) { Map<File, String> changed = new HashMap<>(); Map<File, String> unmerged = new HashMap<>(); -- GitLab