Compare commits
1 commit
Author | SHA1 | Date | |
---|---|---|---|
fa82b5c1eb |
2 changed files with 45 additions and 10 deletions
14
source/app.d
14
source/app.d
|
@ -39,7 +39,15 @@ int main(string[] args)
|
|||
)
|
||||
)
|
||||
.add(new Command("status", "Checking the status of tracked files"))
|
||||
.add(new Command("diff", "Show changed data"))
|
||||
.add(new Command("diff", "Show changed data")
|
||||
.add(new Option("s", "snapshot", "Specify snapshot hash")
|
||||
.optional
|
||||
.validateEachWith(
|
||||
opt => opt.isValidHash,
|
||||
"must contain snapshot hash provided"
|
||||
)
|
||||
)
|
||||
)
|
||||
.add(new Command("size", "Size of snapshots"))
|
||||
.add(new Command("import", "Import snapshot from a tar.gz archive")
|
||||
.add(new Argument("archive", "The path to the tar.gz archive file").required)
|
||||
|
@ -167,7 +175,9 @@ int main(string[] args)
|
|||
snag.initialize(init.flag("force"))
|
||||
)
|
||||
.on("diff", diff =>
|
||||
snag.diff()
|
||||
snag.diff(
|
||||
diff.option("snapshot", "")
|
||||
)
|
||||
)
|
||||
.on("size", size =>
|
||||
snag.size()
|
||||
|
|
|
@ -292,16 +292,41 @@ class Snag {
|
|||
writeln("Backup was restored successfully: ", hash);
|
||||
}
|
||||
|
||||
void diff() {
|
||||
auto result = git(
|
||||
["diff"],
|
||||
"Failed to retrieve changes"
|
||||
);
|
||||
if (result.output.length) {
|
||||
result.output.write;
|
||||
void diff(string hash) {
|
||||
string[] result;
|
||||
if (hash.length) {
|
||||
git(
|
||||
["rev-parse", hash],
|
||||
"This snapshot is not available in the archive"
|
||||
);
|
||||
result = git(
|
||||
["show", hash, "--name-only", "--pretty="],
|
||||
"Failed to retrieve snapshot information"
|
||||
).output.split('\n').filter!(p => !p.empty).array;
|
||||
} else {
|
||||
result = git(
|
||||
["diff", "--name-only"],
|
||||
"Failed to retrieve changes"
|
||||
).output.split('\n').filter!(p => !p.empty).array;
|
||||
}
|
||||
if (!result.length) {
|
||||
writeln("No changes at the moment");
|
||||
return;
|
||||
}
|
||||
writeln("No changes at the moment");
|
||||
if (hash.length)
|
||||
result.each!(e =>
|
||||
git(
|
||||
["show", "--pretty=", hash, "--", e],
|
||||
"Failed to retrieve file information"
|
||||
).output.write
|
||||
);
|
||||
else
|
||||
result.each!(e =>
|
||||
git(
|
||||
["diff", e],
|
||||
"Failed to retrieve file information"
|
||||
).output.write
|
||||
);
|
||||
}
|
||||
|
||||
void exportSnapshot(string path, string hash) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue