#!/usr/bin/env bash fi # Description (FR) if [[ "$TYPE" == "docs" ]]; then DESC="mise à jour de la documentation" elif [[ "$TYPE" == "test" ]]; then DESC="mise à jour des tests" elif [[ "$TYPE" == "chore" ]]; then DESC="mise à jour des dépendances" elif [[ "$TYPE" == "fix" ]]; then DESC="correction" elif [[ "$TYPE" == "refactor" ]]; then DESC="refactorisation" else FILE_COUNT=$(echo "$CHANGED_FILES" | wc -l | tr -d ' ') DESC="mise à jour de ${FILE_COUNT} fichier(s)" fi if [[ -n "$SCOPE" ]]; then COMMIT_MSG="${TYPE}(${SCOPE}): ${DESC}" else COMMIT_MSG="${TYPE}: ${DESC}" fi fi info "Message de commit : $COMMIT_MSG" # ----------------------------- # Commit # ----------------------------- info "Création du commit…" git commit -m "$COMMIT_MSG" -m "Généré avec Claude Code" -m "Co-Authored-By: Claude " # ----------------------------- # Push # ----------------------------- info "Push vers '$REMOTE_NAME'…" if git ls-remote --exit-code --heads "$REMOTE_NAME" "$BRANCH" >/dev/null 2>&1; then git push "$REMOTE_NAME" else git push -u "$REMOTE_NAME" "$BRANCH" fi info "Push terminé" echo "$DIFF_STAT" # ----------------------------- # Lien PR Gitea (best-effort) # ----------------------------- # Format courant : https://host/owner/repo/compare/?expand=1 REMOTE_URL=$(git remote get-url "$REMOTE_NAME" 2>/dev/null || true) extract_host_and_path() { local url="$1" if [[ "$url" =~ ^https?://([^/]+)/(.+)$ ]]; then echo "${BASH_REMATCH[1]}|${BASH_REMATCH[2]}" return 0 elif [[ "$url" =~ ^git@([^:]+):(.+)$ ]]; then echo "${BASH_REMATCH[1]}|${BASH_REMATCH[2]}" return 0 fi return 1 } if HP=$(extract_host_and_path "$REMOTE_URL"); then HOST="${HP%%|*}" PATH_REPO="${HP#*|}" PATH_REPO="${PATH_REPO%.git}" if [[ -z "${GITEA_HOST:-}" || "$HOST" == "$GITEA_HOST" ]]; then warn "Créer une PR : https://${HOST}/${PATH_REPO}/compare/${BRANCH}?expand=1" fi fi