|
14 | 14 | # aicommit -y|--yes # non-interactive; auto-use generated message |
15 | 15 | # aicommit -p|--provider <name> # use a specific AI provider |
16 | 16 | # aicommit -m|--model <name> # optional model override for the chosen provider |
| 17 | +# aicommit --pull # auto pull origin branch with --no-rebase before commit |
17 | 18 | # aicommit -r|--release [bump|ver] # release: patch, minor, major, X.Y.Z, or auto |
18 | 19 | # aicommit -h|--help # show this help |
19 | 20 | # aicommit -v|-V|--version # show version information |
@@ -87,6 +88,7 @@ show_help() { |
87 | 88 | echo -e " ${C_GREEN}--no-push${C_RESET}, ${C_GREEN}-n${C_RESET} Do not push the commit to the remote." |
88 | 89 | echo -e " ${C_GREEN}--yes${C_RESET}, ${C_GREEN}-y${C_RESET} Assume yes: auto-use the generated message." |
89 | 90 | echo -e " ${C_GREEN}--changelog${C_RESET}, ${C_GREEN}-c${C_RESET} Update CHANGELOG.md with this commit." |
| 91 | + echo -e " ${C_GREEN}--pull${C_RESET} Auto pull from origin with --no-rebase before committing." |
90 | 92 | echo -e " ${C_GREEN}--release${C_RESET}, ${C_GREEN}-r${C_RESET} ${C_DIM}[type]${C_RESET} Create a release. Type: patch, minor, major, or X.Y.Z." |
91 | 93 | echo -e " ${C_DIM}If omitted, AI auto-detects the bump type.${C_RESET}" |
92 | 94 | echo -e " ${C_GREEN}-v${C_RESET}, ${C_GREEN}-V${C_RESET}, ${C_GREEN}--version${C_RESET} Show version information." |
@@ -209,13 +211,15 @@ ASSUME_YES=false |
209 | 211 | UPDATE_CHANGELOG=false |
210 | 212 | CLI_PROVIDER="" |
211 | 213 | CLI_MODEL="" |
| 214 | +AUTO_PULL=false |
212 | 215 | RELEASE_MODE=false |
213 | 216 | RELEASE_ARG="" |
214 | 217 |
|
215 | 218 | while (( "$#" )); do |
216 | 219 | case "$1" in |
217 | 220 | --no-push|-n) NO_PUSH=true ;; |
218 | 221 | --yes|-y) ASSUME_YES=true ;; |
| 222 | + --pull) AUTO_PULL=true ;; |
219 | 223 | --changelog|-c) UPDATE_CHANGELOG=true ;; |
220 | 224 | --provider|-p) |
221 | 225 | shift |
@@ -1443,6 +1447,18 @@ if ! $ASSUME_YES; then |
1443 | 1447 | read -p "Press Enter to commit (Ctrl+C to abort) … " |
1444 | 1448 | fi |
1445 | 1449 |
|
| 1450 | +# ---- Auto pull (if requested) ---- |
| 1451 | +if $AUTO_PULL; then |
| 1452 | + CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) |
| 1453 | + echo "Pulling from origin/$CURRENT_BRANCH with --no-rebase..." |
| 1454 | + if git pull --no-rebase origin "$CURRENT_BRANCH"; then |
| 1455 | + echo "✅ Pull completed successfully." |
| 1456 | + else |
| 1457 | + echo "⚠️ Pull failed. Please resolve conflicts and try again." |
| 1458 | + exit 1 |
| 1459 | + fi |
| 1460 | +fi |
| 1461 | + |
1446 | 1462 | # ---- Commit ---- |
1447 | 1463 | git add -A |
1448 | 1464 | git commit -m "$FINAL_MSG" |
|
0 commit comments