docs: update CLAUDE.md and add git helper scripts
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
21
.claude/scripts/git-commit.sh
Normal file
21
.claude/scripts/git-commit.sh
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
# git-commit.sh – Stage all, commit, push
|
||||
# Verwendung: bash .claude/scripts/git-commit.sh "commit message" [minor|patch(default)]
|
||||
set -euo pipefail
|
||||
|
||||
MESSAGE="${1:-}"
|
||||
BUMP="${2:-patch}"
|
||||
|
||||
if [[ -z "$MESSAGE" ]]; then
|
||||
echo "Verwendung: bash .claude/scripts/git-commit.sh \"message\" [patch|minor]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ROOT="$(git rev-parse --show-toplevel)"
|
||||
cd "$ROOT"
|
||||
|
||||
git add -A
|
||||
git commit -m "$MESSAGE
|
||||
|
||||
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>"
|
||||
git push
|
||||
61
.claude/scripts/git-pr.sh
Normal file
61
.claude/scripts/git-pr.sh
Normal file
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env bash
|
||||
# git-pr.sh – Pull-Request via Gitea API erstellen und optional mergen
|
||||
#
|
||||
# Verwendung:
|
||||
# bash .claude/scripts/git-pr.sh create <head> <base> "<title>" ["<body>"]
|
||||
# bash .claude/scripts/git-pr.sh merge <pr_number> [squash|merge|rebase]
|
||||
# bash .claude/scripts/git-pr.sh list [open|closed]
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
REPO="Admin/gartenmanager"
|
||||
API="https://tea.jr-family.de/api/v1"
|
||||
|
||||
get_token() {
|
||||
git credential fill <<'EOF' | grep "^password=" | cut -d= -f2-
|
||||
protocol=https
|
||||
host=tea.jr-family.de
|
||||
EOF
|
||||
}
|
||||
|
||||
CMD="${1:-}"
|
||||
|
||||
case "$CMD" in
|
||||
create)
|
||||
HEAD="${2:?'head branch fehlt'}"
|
||||
BASE="${3:?'base branch fehlt'}"
|
||||
TITLE="${4:?'titel fehlt'}"
|
||||
BODY="${5:-}"
|
||||
TOKEN=$(get_token)
|
||||
RESULT=$(curl -s -X POST "$API/repos/$REPO/pulls" \
|
||||
-H "Authorization: Bearer $TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"head\":\"$HEAD\",\"base\":\"$BASE\",\"title\":\"$TITLE\",\"body\":\"$BODY\"}")
|
||||
PR_NUM=$(echo "$RESULT" | python3 -c "import sys,json; r=json.load(sys.stdin); print(r.get('number','ERR: '+str(r.get('message',''))))")
|
||||
echo "PR #$PR_NUM erstellt: $TITLE ($HEAD → $BASE)"
|
||||
;;
|
||||
|
||||
merge)
|
||||
PR_NUM="${2:?'PR-Nummer fehlt'}"
|
||||
STYLE="${3:-squash}"
|
||||
TOKEN=$(get_token)
|
||||
curl -s -X POST "$API/repos/$REPO/pulls/$PR_NUM/merge" \
|
||||
-H "Authorization: Bearer $TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"Do\":\"$STYLE\"}"
|
||||
echo "PR #$PR_NUM gemergt ($STYLE)"
|
||||
;;
|
||||
|
||||
list)
|
||||
STATE="${2:-open}"
|
||||
TOKEN=$(get_token)
|
||||
curl -s "$API/repos/$REPO/pulls?state=$STATE&limit=20" \
|
||||
-H "Authorization: Bearer $TOKEN" | \
|
||||
python3 -c "import sys,json; [print(f\"#{r['number']} [{r['state']}] {r['title']} ({r['head']['label']} → {r['base']['label']})\") for r in json.load(sys.stdin)]"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Verwendung: bash .claude/scripts/git-pr.sh [create|merge|list] ..."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
36
.claude/scripts/git-switch.sh
Normal file
36
.claude/scripts/git-switch.sh
Normal file
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
# git-switch.sh – Branch wechseln oder erstellen, remote aktualisieren
|
||||
#
|
||||
# Verwendung:
|
||||
# bash .claude/scripts/git-switch.sh <branch> – wechseln (pull wenn vorhanden)
|
||||
# bash .claude/scripts/git-switch.sh <branch> create – neu aus aktuellem Branch
|
||||
# bash .claude/scripts/git-switch.sh <branch> from <base> – neu aus <base>
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
BRANCH="${1:?'Branch-Name fehlt'}"
|
||||
MODE="${2:-switch}"
|
||||
BASE="${3:-}"
|
||||
|
||||
ROOT="$(git rev-parse --show-toplevel)"
|
||||
cd "$ROOT"
|
||||
|
||||
case "$MODE" in
|
||||
switch)
|
||||
git fetch origin "$BRANCH" 2>/dev/null || true
|
||||
git checkout "$BRANCH" 2>/dev/null || git checkout -b "$BRANCH"
|
||||
git pull origin "$BRANCH" 2>/dev/null || true
|
||||
;;
|
||||
create)
|
||||
git checkout -b "$BRANCH"
|
||||
git push -u origin "$BRANCH"
|
||||
;;
|
||||
from)
|
||||
BASE="${3:?'Basis-Branch fehlt'}"
|
||||
git fetch origin "$BASE"
|
||||
git checkout -b "$BRANCH" "origin/$BASE"
|
||||
git push -u origin "$BRANCH"
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "Aktiver Branch: $(git branch --show-current)"
|
||||
11
.claude/scripts/git-sync.sh
Normal file
11
.claude/scripts/git-sync.sh
Normal file
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
# git-sync.sh – aktuellen Branch mit Remote synchronisieren (pull + push)
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(git rev-parse --show-toplevel)"
|
||||
cd "$ROOT"
|
||||
|
||||
BRANCH=$(git branch --show-current)
|
||||
git pull origin "$BRANCH"
|
||||
git push origin "$BRANCH"
|
||||
echo "Synchronisiert: $BRANCH"
|
||||
Reference in New Issue
Block a user