Skip to content

Commit 616e7a1

Browse files
authored
Added warning message for todo.sh archive (#399)
1 parent 0e7c091 commit 616e7a1

File tree

5 files changed

+20
-10
lines changed

5 files changed

+20
-10
lines changed

tests/t1900-archive.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,9 @@ test_todo_session 'list after archive' <<EOF
3232
TODO: 5 of 5 tasks shown
3333
EOF
3434

35+
test_todo_session 'archive warning message' <<EOF
36+
>>> todo.sh archive
37+
TODO: $HOME/todo.txt does not contain any done tasks.
38+
EOF
39+
3540
test_done

tests/t1950-report.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ EOF
1616

1717
test_todo_session 'create new report' <<EOF
1818
>>> todo.sh report
19-
TODO: $HOME/todo.txt archived.
19+
TODO: $HOME/todo.txt does not contain any done tasks.
2020
2009-02-13T04:40:00 5 0
2121
TODO: Report file updated.
2222
@@ -38,7 +38,7 @@ x 2009-02-13 smell the coffee +wakeup
3838
TODO: $HOME/todo.txt archived.
3939
4040
>>> todo.sh report
41-
TODO: $HOME/todo.txt archived.
41+
TODO: $HOME/todo.txt does not contain any done tasks.
4242
2009-02-13T04:40:00 4 1
4343
TODO: Report file updated.
4444
@@ -83,7 +83,7 @@ test_todo_session 'report is unchanged when no changes' <<EOF
8383
2009-02-13T04:40:00 3 2
8484
8585
>>> todo.sh report
86-
TODO: $HOME/todo.txt archived.
86+
TODO: $HOME/todo.txt does not contain any done tasks.
8787
2009-02-13T04:40:00 3 2
8888
TODO: Report file is up-to-date.
8989

tests/t2200-no-done-report-files.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ test_expect_success 'no done file has been created by the archiving' '[ ! -e don
3838

3939
test_todo_session 'perform report' <<EOF
4040
>>> todo.sh -d test.cfg report
41-
TODO: ./todo.txt archived.
41+
TODO: ./todo.txt does not contain any done tasks.
4242
2009-02-13T04:40:00 0 0
4343
TODO: Report file updated.
4444
EOF

tests/t9999-testsuite_example.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ TODO: $HOME/todo.txt archived.
8585
TODO: 5 of 5 tasks shown
8686
8787
>>> todo.sh report
88-
TODO: $HOME/todo.txt archived.
88+
TODO: $HOME/todo.txt does not contain any done tasks.
8989
2009-02-13T04:40:00 5 1
9090
TODO: Report file updated.
9191

todo.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,11 +1172,16 @@ case $action in
11721172
"archive" )
11731173
# defragment blank lines
11741174
sed -i.bak -e '/./!d' "$TODO_FILE"
1175-
[ "$TODOTXT_VERBOSE" -gt 0 ] && grep "^x " "$TODO_FILE"
1176-
grep "^x " "$TODO_FILE" >> "$DONE_FILE"
1177-
sed -i.bak '/^x /d' "$TODO_FILE"
1178-
if [ "$TODOTXT_VERBOSE" -gt 0 ]; then
1179-
echo "TODO: $TODO_FILE archived."
1175+
if grep "^x " "$TODO_FILE" >> "$DONE_FILE"; then
1176+
[ "$TODOTXT_VERBOSE" -gt 0 ] && grep "^x " "$TODO_FILE"
1177+
sed -i.bak '/^x /d' "$TODO_FILE"
1178+
if [ "$TODOTXT_VERBOSE" -gt 0 ]; then
1179+
echo "TODO: $TODO_FILE archived."
1180+
fi
1181+
else
1182+
if [ "$TODOTXT_VERBOSE" -gt 0 ]; then
1183+
echo "TODO: $TODO_FILE does not contain any done tasks."
1184+
fi
11801185
fi
11811186
;;
11821187

0 commit comments

Comments
 (0)