Skip to content

Commit 921eb19

Browse files
authored
Fix script name in usage examples
Updated script to reflect correct file name in examples and comments.
1 parent 51d061d commit 921eb19

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/change_commit_date.sh

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,22 @@ set -euo pipefail
1818
#
1919
# Examples:
2020
# # 1) Set latest commit to specific day (random time) in UTC+2
21-
# ./commit_date_tools.sh amend-latest --date 25-12-2022
21+
# ./change_commit_date.sh amend-latest --date 25-12-2022
2222
#
2323
# # 1b) Set latest commit to specific day & time with custom tz
24-
# ./commit_date_tools.sh amend-latest --date 25-12-2022 --time 14:30 --tz +0530
24+
# ./change_commit_date.sh amend-latest --date 25-12-2022 --time 14:30 --tz +0530
2525
#
2626
# # 2) Shift entire history forward 7 hours
27-
# ./commit_date_tools.sh shift --hours 7
27+
# ./change_commit_date.sh shift --hours 7
2828
#
2929
# # 2b) Shift entire history back 2 days and 3 hours, timezone +0200
30-
# ./commit_date_tools.sh shift --days -2 --hours -3 --tz +0200
30+
# ./change_commit_date.sh shift --days -2 --hours -3 --tz +0200
3131
#
3232
# # 3) Move all commits into daytime (random hour in window)
33-
# ./commit_date_tools.sh move --to day
33+
# ./change_commit_date.sh move --to day
3434
#
3535
# # 3b) Move to night hours with custom windows and timezone
36-
# ./commit_date_tools.sh move --to night --night-window 21-23,00-04 --tz -0500
36+
# ./change_commit_date.sh move --to night --night-window 21-23,00-04 --tz -0500
3737
#
3838
# After rewriting history:
3939
# git push --force-with-lease
@@ -42,7 +42,11 @@ set -euo pipefail
4242
# ---------- Utilities ----------
4343

4444
# Pick GNU date (Linux: date, macOS: gdate)
45-
DATE_BIN="$(command -v gdate || command -v date)"
45+
if command -v gdate >/dev/null 2>&1; then
46+
DATE_BIN="$(command -v gdate)"
47+
else
48+
DATE_BIN="$(command -v date)"
49+
fi
4650
if ! "$DATE_BIN" -d "@0" +%s >/dev/null 2>&1; then
4751
echo "Error: GNU 'date' required. On macOS: brew install coreutils (use gdate)." >&2
4852
exit 1
@@ -313,7 +317,8 @@ move_history() {
313317
# 2) Second pass: assign evenly spaced times inside window per day, preserving order
314318
local STATE
315319
STATE="$(mktemp -d)"
316-
trap 'rm -rf "$STATE"' EXIT
320+
# Clean up when this function returns; safe with set -u
321+
trap '[[ -n "${STATE:-}" ]] && rm -rf "$STATE"' RETURN
317322
mkdir -p "$STATE/map"
318323

319324
declare -A DAY_INDEX=()

0 commit comments

Comments
 (0)