diff --git a/source/snag/core/core.d b/source/snag/core/core.d index e70ce62..cf1f65c 100644 --- a/source/snag/core/core.d +++ b/source/snag/core/core.d @@ -44,6 +44,22 @@ class Snag { return result; } + private string gitStatus(string shortStatus, bool formatted = false) { + immutable string[string] statusMap = [ + "??": "Untracked", + "A": "Added", + "M": "Modified", + "D": "Deleted", + "R": "Renamed", + "C": "Copied", + "U": "Unmerged", + "T": "Type changed", + "!": "Ignored" + ]; + string fullStatus = statusMap.get(shortStatus, shortStatus); + return formatted && fullStatus.length < 8 ? fullStatus ~ "\t" : fullStatus; + } + void initialize(bool force) { auto result = execute(_baseCommand ~ ["rev-parse", "--git-dir"]); !force && !result.status && @@ -84,9 +100,11 @@ class Snag { return; } writeln("The following list of files requires backup:"); - result.output.split('\n').filter!(e => !e.strip.empty).each!((e) { - writefln("\t/%s", e.strip.split[1]); - }); + result.output.split('\n')[0..$-1].map!(e => + e.strip.split + ).each!(e => + writefln("\t%s\t/%s", gitStatus(e[0], true), e[1]) + ); } void create(string comment, string author, string email) {