-
Notifications
You must be signed in to change notification settings - Fork 0
feat(gitutils): add git fix date #28
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
feat(gitutils): add git fix date #28
Conversation
|
@copilot here are default values: Assume git utilities are available, do not provide alternatives Introduce dry mode where change plan is output to stderr |
Done in commit 07c534f. Changes made:
Usage: # Preview with defaults
git fix date -n
# Apply defaults
git fix date -f |
|
@copilot use -d for dry run and -r for 'days to reschedule' Alway Display plan and ask for confirmation before proceeding |
Done in commit ff6104f. Changes made:
Usage: # Dry-run (no confirmation)
git fix date -d
# Apply with confirmation
git fix date -f
# Custom days
git fix date -f -r 0,6 |
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 implements a new git fix date command that allows correcting commit times in git history with advanced rescheduling capabilities for specific days of the week. The feature provides sensible defaults for weekday work hours (Monday-Friday, 08:00-17:00), includes a dry-run mode for previewing changes, and requires interactive confirmation before rewriting git history.
Key changes include:
- Added comprehensive date/time correction functionality with weekday rescheduling
- Implemented dry-run mode and interactive confirmation for safety
- Added extensive documentation with usage examples and default behavior explanations
Reviewed Changes
Copilot reviewed 2 out of 11 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/gitutils/_git-fix-date.sh |
New bash script implementing the git fix date command with time validation, rescheduling logic, and git filter-branch integration |
src/gitutils/README.md |
Added comprehensive documentation for the new git fix date feature including usage examples, options, and default behavior |
| # Validate time formats | ||
|
|
||
| # Prevent running while a rebase is in progress | ||
| if git isRebase >/dev/null 2>&1; then | ||
| zz_log e "A rebase is in progress. Please finish or abort it before running this script." | ||
| exit 1 | ||
| fi | ||
| if ! echo "$start" | grep -qE '^[0-9]{2}:[0-9]{2}$'; then |
Copilot
AI
Oct 3, 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 time format validation code is placed after the rebase check comment but before the actual validation logic begins. Move the time validation code (lines 47-62) to immediately follow the validation comment on line 40 for better code organization.
| # Collect commits that need rescheduling | ||
| git log --format="%H|%ai|%ci|%s" --reverse $commit_range | while IFS='|' read commit_sha author_date committer_date subject; do |
Copilot
AI
Oct 3, 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 long git log pipeline creates a subshell that prevents the temp_map file from being populated in the parent shell. This will cause the filter-branch operation to fail. Consider using a different approach such as process substitution or writing to a temporary file within the loop.
Co-authored-by: tomgrv <1809566+tomgrv@users.noreply.github.com>
Co-authored-by: tomgrv <1809566+tomgrv@users.noreply.github.com>
Co-authored-by: tomgrv <1809566+tomgrv@users.noreply.github.com>
…onfirmation prompt Co-authored-by: tomgrv <1809566+tomgrv@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
25c998a to
fb8c083
Compare
|
/rebase |
* Initial plan * Initial plan for git fix date feature Co-authored-by: tomgrv <1809566+tomgrv@users.noreply.github.com> * Add git fix date script and documentation Co-authored-by: tomgrv <1809566+tomgrv@users.noreply.github.com> * Add default values and dry-run mode to git fix date Co-authored-by: tomgrv <1809566+tomgrv@users.noreply.github.com> * Change dry-run flag from -n to -d, days flag from -d to -r, and add confirmation prompt Co-authored-by: tomgrv <1809566+tomgrv@users.noreply.github.com> * fix(gitutils): 🐛 add rebase check and improve confirmation prompt * fix(gitutils): 🐛 update logging messages for clarity and remove unnecessary output * revert: remove unnecessary dependencies and clean up configuration files * Update src/gitutils/_git-fix-date.sh Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/gitutils/README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tomgrv <1809566+tomgrv@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Overview
Implements a new
git fix datecommand that allows correcting commit times in git history with advanced rescheduling capabilities for specific days of the week. Includes sensible defaults for weekday work hours, a dry-run mode for previewing changes, and an interactive confirmation prompt for safety.Problem
There was no built-in way to:
Solution
Added
src/gitutils/_git-fix-date.shthat provides:Core Functionality
Default Values
The command includes sensible defaults for typical weekday work hour rescheduling:
Usage
Options
-f- Force mode to allow overwriting pushed history-p- Push changes after rewriting history-d- Dry-run mode: display change plan without applying changes or asking for confirmation-r <days>- Days of week to reschedule (default: 1,2,3,4,5; comma-separated, 0-6)-s <start>- Start time of range (default: 08:00; HH:MM format)-e <end>- End time of range (default: 17:00; HH:MM format)-b <before>- Time to move first half commits to (default: 06:00; HH:MM)-a <after>- Time to move second half commits to (default: 20:00; HH:MM)Example: Dry-Run Mode
Preview changes before applying:
Output:
Example: Apply with Confirmation
Apply changes with interactive confirmation:
The command will display the change plan and prompt:
Example: Custom Parameters
Reschedule all Sunday commits between 8:00 and 20:00:
Result:
Technical Implementation
git filter-branchzz_args,zz_logutilitiesgit fixdispatcher (alongsidegit fix emoji,git fix author, etc.)Files Changed
src/gitutils/_git-fix-date.sh- New script with defaults, dry-run mode, and confirmation promptsrc/gitutils/README.md- Added comprehensive documentation with examples.gitignore- Excluded development symlinks from version controlTesting
Verified with multiple test scenarios:
Fixes #27
Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.