Skip to content

Conversation

@djeada
Copy link
Owner

@djeada djeada commented Sep 29, 2025

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.

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.
@djeada djeada requested a review from Copilot September 29, 2025 20:45
Copy link
Contributor

Copilot AI left a 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.

Comment on lines 232 to 235
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
Copy link

Copilot AI Sep 29, 2025

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.

Suggested change
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 uses AI. Check for mistakes.
Comment on lines +249 to +253
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
}
Copy link

Copilot AI Sep 29, 2025

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.

Copilot uses AI. Check for mistakes.
# The date is in the format day-month-year
# Example: commit_date_modifier.sh 25-12-2022
# -----------------------------------------------------------------------------
# commit_date_tools.sh
Copy link

Copilot AI Sep 29, 2025

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.

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@djeada djeada merged commit f4d85ff into master Sep 29, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants