@@ -28,6 +28,8 @@ GLOBS=()
2828
2929if [[ -n " $usage_globs " ]]; then
3030 IFS=' ' read -r -a GLOBS <<< " $usage_globs"
31+ elif [[ $# -gt 0 ]]; then
32+ GLOBS=(" $@ " )
3133fi
3234
3335MAIN_BRANCH=" ${usage_base_branch:- main} "
@@ -88,6 +90,8 @@ switch_to_target_if_not_in_rebase()
8890 echo " We'll stash any uncommitted changes first."
8991 git stash push -u -m " temp-stash-before-rebase-resolve-$( date +%s) "
9092 git checkout " $TARGET_BRANCH "
93+ elif ! already_in_rebase; then
94+ git stash push -u -m " temp-stash-before-rebase-resolve-$( date +%s) "
9195 fi
9296}
9397
@@ -186,7 +190,7 @@ move_to_next_conflict()
186190 conflicted=$( conflicted_files)
187191 if [[ -z " $conflicted " ]] && already_in_rebase; then
188192 echo " All conflicts resolved. Continuing rebase..."
189- git rebase --continue
193+ git rebase --continue || true
190194 elif ! already_in_rebase; then
191195 echo " Looks like we're all done here. Get back to work!"
192196 exit 0
@@ -196,30 +200,34 @@ move_to_next_conflict()
196200main ()
197201 {
198202 switch_to_target_if_not_in_rebase
203+ if ! already_in_rebase; then
204+ if ! git rebase " $MAIN_BRANCH " ; then
205+ echo " Rebase paused due to conflicts; continuing automated resolution..."
206+ fi
207+ fi
199208 while true ; do
200209 local conflicted
201210 local staged
202211 staged=$( staged_files)
203212 conflicted=$( conflicted_files)
204- if [[ -z " $ conflicted" ]]; then
213+ if [[ ${ # conflicted[@]} -eq 0 ]]; then
205214 # If no conflicts but there are staged changes, handle them
206- if [[ " $ staged" ]]; then
215+ if [[ ${ # staged[@]} -gt 0 ]]; then
207216 handle_staged_changes " $staged "
208217 else
209218 move_to_next_conflict
210219 sleep 1
211220 fi
212- else
213- handle_conflicts " $staged "
214- move_to_next_conflict
215- sleep 1
216221 fi
222+ handle_conflicts " $staged "
223+ move_to_next_conflict
224+ sleep 1
217225 done
218226}
219227
220228# just getting the first element is OK since we just need to verify that at least one glob was provided
221229# shellcheck disable=SC2128
222- if [[ -z " $ GLOBS" ]]; then
230+ if [[ ${ # GLOBS[@]} -eq 0 ]]; then
223231 echo " You must specify at least one file glob that requires manual review during conflict resolution."
224232 exit 1
225233fi
0 commit comments