From c388d01a2fd9314b83b596b982753be59d942b9b Mon Sep 17 00:00:00 2001 From: Alexander Zhirov Date: Wed, 28 May 2025 00:20:27 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=BD=D1=84=D0=BE=D1=80=D0=BC=D0=B0?= =?UTF-8?q?=D1=82=D0=B8=D0=B2=D0=BD=D1=8B=D0=B9=20=D0=B2=D1=8B=D0=B2=D0=BE?= =?UTF-8?q?=D0=B4=20=D0=BF=D1=80=D0=B8=20=D0=B2=D1=8B=D0=B7=D0=BE=D0=B2?= =?UTF-8?q?=D0=B5=20status?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/snag/core/core.d | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) 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) {