Skip to content

Commit 633ea81

Browse files
committed
refactor(gitutils): ♻️ improve scripts
1 parent 0119d55 commit 633ea81

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/gitutils/_git-autorebase.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ eval $(
55
zz_args "Automatically handles non-interactive rebasing with conflict resolution" $0 "$@" <<-help
66
f - force allow overwriting pushed history
77
p - push push to remote after rebase
8-
a - auto fully automatic mode - no prompts
8+
a - autosquash Apply autosquash (default: off)
99
n - no-lock don't automatically manage lock files
1010
s strategy strategy strategy for conflicts (default: theirs)
1111
o onto onto rebase onto (default: origin/main)
12-
- sha sha commit/branch to rebase onto (default: origin/main)
13-
- branch branch alias for sha
12+
b branch branch branch to rebase (default: current branch)
13+
- sha sha commit/branch to rebase onto (default: origin/main)
1414
help
1515
)
1616

1717
# Set defaults
1818
strategy="${strategy:-theirs}"
19-
sha="${sha:-origin/main}"
19+
sha=$(git getcommit $force $sha)
2020
lockfile_patterns="${no_lock:+}${no_lock:-package-lock.json yarn.lock composer.lock pnpm-lock.yaml go.sum}"
2121

2222
# Navigate to repository root and validate state
@@ -59,7 +59,7 @@ current_branch=$(git branch --show-current)
5959
zz_log i "Rebasing '$current_branch' onto '$sha' with '$strategy' strategy"
6060

6161
# Perform rebase with automatic conflict resolution
62-
if ! git rebase --strategy-option="$strategy" --autosquash --autostash --reschedule-failed-exec --exec 'git hook run --ignore-missing pre-commit -- HEAD HEAD~1 && git commit --amend --no-edit --no-verify' --no-verify ${onto:+--onto "$onto"} "$sha" "$branch"; then
62+
if ! git rebase --strategy-option="$strategy" ${auto:+--autosquash} --autostash --reschedule-failed-exec --exec 'git hook run --ignore-missing pre-commit -- HEAD HEAD~1 && git commit --amend --no-edit --no-verify' --no-verify ${onto:+--onto "$onto"} "$sha" "$branch"; then
6363
zz_log w "Resolving conflicts automatically..."
6464

6565
attempts=0

src/gitutils/_git-fix-del.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ fi
4343
zz_log i "Deleting commit: $sha"
4444

4545
# Attempt deletion with fallback to autorebase
46-
if ! git autorebase ${auto:+-a} -s "$strategy" -o "$sha^" "$sha" HEAD ; then
46+
if ! git autorebase ${auto:+-a} -s "$strategy" -o "$sha^" "$sha" ; then
4747
zz_log e "Failed to delete commit $sha. Please resolve conflicts manually."
4848
exit 1
4949
else

0 commit comments

Comments
 (0)