Skip to content

Commit 7d9d59d

Browse files
authored
align try-summary and shell fallback (#210)
Resolves #201. adds a `-q` flag for quieter output from `try-summary` (not something try will produce); aligns try-summary and the built-in shell fallback output
1 parent 1d5160e commit 7d9d59d

2 files changed

Lines changed: 20 additions & 9 deletions

File tree

test/summary.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,15 @@ echo 'fail' >file_2.txt
3232
touch target
3333

3434
try_example_dir=$(mktemp -d)
35-
"$TRY" -D "$try_example_dir" "touch file_1.txt; echo test >file_2.txt; rm file.txt.gz; rm target; mkdir target; mkdir new_dir" || exit 1
35+
"$TRY" -D "$try_example_dir" "touch file_1.txt; echo test >file_2.txt; rm file.txt.gz; rm target; mkdir target; mkdir -p new_dir/nested" || exit 1
3636
"$TRY" summary "$try_example_dir" >summary.out || exit 2
3737

38+
cat summary.out
39+
3840
# Check that the summary correctly identifies every change
39-
grep -qx -e "$PWD/file_1.txt (added)" summary.out || exit 3
40-
grep -qx -e "$PWD/file_2.txt (modified)" summary.out || exit 4
41-
grep -qx -e "$PWD/file.txt.gz (deleted)" summary.out || exit 5
42-
grep -qx -e "$PWD/target (replaced with dir)" summary.out || exit 6
43-
grep -qx -e "$PWD/new_dir (created dir)" summary.out || exit 7
41+
grep -qx -e "$PWD/file_1.txt (added)" summary.out || exit 3
42+
grep -qx -e "$PWD/file_2.txt (modified)" summary.out || exit 4
43+
grep -qx -e "$PWD/file.txt.gz (deleted)" summary.out || exit 5
44+
grep -qx -e "$PWD/target (replaced with dir)" summary.out || exit 6
45+
grep -qx -e "$PWD/new_dir (created dir)" summary.out || exit 7
46+
grep -qx -e "$PWD/new_dir/nested (created dir)" summary.out || exit 8

utils/try-summary.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,21 @@ void show_change(char *local_file, char *msg) {
2828
}
2929

3030
void usage(int status) {
31-
fprintf(stderr, "Usage: try-summary [-i IGNORE_FILE] SANDBOX_DIR\n");
31+
fprintf(stderr, "Usage: try-summary [-q] [-i IGNORE_FILE] SANDBOX_DIR\n");
3232
exit(status);
3333
}
3434

3535
int main(int argc, char *argv[]) {
36+
int skip_new_directories = 0;
3637
int opt;
37-
while ((opt = getopt(argc, argv, "hvi:")) != -1) {
38+
while ((opt = getopt(argc, argv, "hvqi:")) != -1) {
3839
switch (opt) {
3940
case 'i':
4041
load_ignores("try-summary", optarg);
4142
break;
43+
case 'q':
44+
skip_new_directories = 1;
45+
break;
4246
case 'v':
4347
fprintf(stderr, "try-summary version " TRY_VERSION "\n");
4448
exit(0);
@@ -114,7 +118,11 @@ int main(int argc, char *argv[]) {
114118
show_change(local_file, "created dir");
115119

116120
// don't traverse children, we copied the whole thing
117-
fts_set(fts, ent, FTS_SKIP);
121+
// only done when -q flag is supplied
122+
// try will not supply this flag by default
123+
if (skip_new_directories) {
124+
fts_set(fts, ent, FTS_SKIP);
125+
}
118126
break;
119127
}
120128

0 commit comments

Comments
 (0)