-
Notifications
You must be signed in to change notification settings - Fork 59
Refactor commit date modifier to support multiple modes #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Updated the script to provide powerful Git commit-date tools including options to amend the latest commit date, shift all commits, and move commits into day or night hours. Enhanced usage examples and added timezone handling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors a simple commit date modifier script into a comprehensive Git commit-date tools utility with multiple operating modes. The script now supports three distinct modes: amending the latest commit date, shifting all commits by a time offset, and moving all commits into specific time windows (day/night hours).
- Replaced basic single-date modification with three powerful modes: amend-latest, shift, and move
- Added comprehensive timezone handling with customizable offset support
- Implemented sophisticated argument parsing with validation and help documentation
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| git filter-branch -f --tag-name-filter cat --env-filter " | ||
| tz='${TZ_OFFSET}' | ||
| tz_secs=$(tz_to_seconds '${TZ_OFFSET}') # <- will be substituted by this script (not inside env-filter) | ||
| " -- --branches --tags >/dev/null 2>&1 && true |
Copilot
AI
Sep 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running git filter-branch twice is inefficient and potentially problematic. The first filter-branch call appears incomplete and unnecessary since the actual logic is implemented in the second call.
| git filter-branch -f --tag-name-filter cat --env-filter " | |
| tz='${TZ_OFFSET}' | |
| tz_secs=$(tz_to_seconds '${TZ_OFFSET}') # <- will be substituted by this script (not inside env-filter) | |
| " -- --branches --tags >/dev/null 2>&1 && true |
| to_epoch() { $DATE_BIN -d \"\$1\" +%s; } | ||
| from_local_YmdHMS_to_epoch() { # args: Y M D H M S, interpret as LOCAL (tz offset), return UTC epoch | ||
| local Y=\"\$1\" Mo=\"\$2\" D=\"\$3\" H=\"\$4\" Mi=\"\$5\" S=\"\$6\" | ||
| $DATE_BIN -d \"\${Y}-\${Mo}-\${D} \${H}:\${Mi}:\${S} UTC\" +%s | ||
| } |
Copilot
AI
Sep 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The from_local_YmdHMS_to_epoch function is defined but never used in the script. This creates unnecessary complexity and should be removed.
| # The date is in the format day-month-year | ||
| # Example: commit_date_modifier.sh 25-12-2022 | ||
| # ----------------------------------------------------------------------------- | ||
| # commit_date_tools.sh |
Copilot
AI
Sep 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script filename in the comment doesn't match the actual filename 'change_commit_date.sh'. This should be updated to reflect the correct filename.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Updated the script to provide powerful Git commit-date tools including options to amend the latest commit date, shift all commits, and move commits into day or night hours. Enhanced usage examples and added timezone handling.