Skip to content

Commit 18c82e4

Browse files
committed
publish_edition: add checks for next edition
1 parent 9d286fb commit 18c82e4

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

publish_edition.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ today=$(date "+%Y-%m-%d")
5757
next_month=$(LANG=C date "+%B %Y")
5858
prev_month=$(LANG=C date --date="$today - 1 month" "+%B %Y")
5959

60-
6160
# Publish current draft
6261

6362
git mv "$src_dir"/edition-$cur.md "$dst_dir"/$today-edition-$cur.markdown
@@ -68,7 +67,13 @@ git commit -m "Publish rn-$cur in $dst_dir/"
6867

6968
git cherry-pick "$last_draft_commit"
7069

71-
git mv "$src_dir"/edition-$cur.md "$src_dir"/edition-$next.md
70+
cur_ed="$src_dir/edition-$cur.md"
71+
next_ed="$src_dir/edition-$next.md"
72+
73+
test -f "$cur_ed" || die "cannot find '$cur_ed'"
74+
75+
git mv "$cur_ed" "$next_ed" ||
76+
die "failed to 'git mv $cur_ed $next_ed'"
7277

7378
add_order_suffix() {
7479
perl -e '
@@ -95,7 +100,7 @@ perl -pi -e "
95100
s/$today/$nextdate/g;
96101
s/$prev_month/$next_month/g;
97102
98-
" "$src_dir"/edition-$next.md
103+
" "$next_ed"
99104

100-
git commit --amend -m "Add draft for rn-$next" "$src_dir"/edition-$cur.md "$src_dir"/edition-$next.md
105+
git commit --amend -m "Add draft for rn-$next" "$cur_ed" "$next_ed"
101106

0 commit comments

Comments
 (0)