From 4242a33a5cec67371b55279857bd9781fe22933b Mon Sep 17 00:00:00 2001 From: Florian Heck <florian.heck@hotmail.de> Date: Wed, 19 Oct 2016 12:43:10 +0200 Subject: [PATCH] changed status to contain path to changed/unmerged files --- .../fim/seibt/gitwrapper/repo/Status.java | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 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 d3c5382..6b4113d 100644 --- a/src/de/uni_passau/fim/seibt/gitwrapper/repo/Status.java +++ b/src/de/uni_passau/fim/seibt/gitwrapper/repo/Status.java @@ -1,7 +1,10 @@ package de.uni_passau.fim.seibt.gitwrapper.repo; -import java.io.File; -import java.util.*; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -9,15 +12,15 @@ public class Status { private static final Pattern STATUS_ENTRY = Pattern.compile("(.?.) (?:.*? )?(.*?)\0"); public final String id; - public final Map<File, String> changed; - public final Map<File, String> unmerged; + public final Map<Path, String> changed; + public final Map<Path, String> unmerged; /** * @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) { + private Status(String id, Map<Path, String> changed, Map<Path, String> unmerged) { this.id = id; this.changed = Collections.unmodifiableMap(changed); this.unmerged = Collections.unmodifiableMap(unmerged); @@ -49,12 +52,12 @@ public class Status { } else { if (!unmerged.isEmpty()) { out = "Unmerged files:"; - out += unmerged.keySet().stream().map(File::getPath).reduce("", (list, file) -> String.join("\n", list, file)); + out += unmerged.keySet().stream().map(Path::toString).reduce("", (list, file) -> String.join("\n", list, file)); out += "\n"; } if (!changed.isEmpty()) { out += "Changed files:"; - out += changed.keySet().stream().map(File::getPath).reduce("", (list, file) -> String.join("\n", list, file)); + out += changed.keySet().stream().map(Path::toString).reduce("", (list, file) -> String.join("\n", list, file)); out += "\n"; } } @@ -70,12 +73,12 @@ public class Status { * @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<>(); + Map<Path, String> changed = new HashMap<>(); + Map<Path, String> unmerged = new HashMap<>(); Matcher matcher = STATUS_ENTRY.matcher(gitOutput); while (matcher.find()) { // used new path, if file was moved - File file = new File(matcher.group(2)); + Path file = Paths.get(matcher.group(2)); String code = matcher.group(1).toUpperCase(); if (code.contains("U")) { unmerged.put(file, code); -- GitLab