Add gitea-merge.sh for complete merge workflow
- Creates gitea-merge.sh: rebase merge, delete branch, close PR - Updates CLAUDE.md: simplified git workflow using new script - Adds model selection reminder to general-instructions.json - Documents Gitea API commands in CLAUDE.md 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
29
CLAUDE.md
29
CLAUDE.md
@@ -88,24 +88,35 @@ This repo uses Gitea (not GitHub). Follow this workflow:
|
|||||||
3. **Rebase onto main**: `git rebase origin/main`
|
3. **Rebase onto main**: `git rebase origin/main`
|
||||||
4. **Push branch**: `git push -u origin feature/branch-name`
|
4. **Push branch**: `git push -u origin feature/branch-name`
|
||||||
5. **Create PR**: `~/.claude/automation/gitea-pr.sh "PR Title" "Description"`
|
5. **Create PR**: `~/.claude/automation/gitea-pr.sh "PR Title" "Description"`
|
||||||
6. **Merge with rebase** (after user approval):
|
6. **Merge** (after user approval): `~/.claude/automation/gitea-merge.sh`
|
||||||
```bash
|
- Rebases onto main and pushes
|
||||||
git checkout main && git rebase feature/branch-name && git push
|
- Deletes local and remote branch
|
||||||
```
|
- Closes PR via API
|
||||||
|
|
||||||
Notes:
|
Notes:
|
||||||
- Use rebase, not merge commits
|
|
||||||
- Stash uncommitted state files before switching branches
|
|
||||||
- Delete feature branches after merge
|
|
||||||
- Gitea token stored at `~/.config/gitea-token`
|
- Gitea token stored at `~/.config/gitea-token`
|
||||||
- PRs show as "closed" (not "merged") after rebase - expected
|
|
||||||
|
|
||||||
### PR Review Policy
|
### PR Review Policy
|
||||||
|
|
||||||
| Repo Type | Review Process |
|
| Repo Type | Review Process |
|
||||||
|-----------|----------------|
|
|-----------|----------------|
|
||||||
| ~/.claude | Linting/validation only (shellcheck, JSON/YAML syntax, Python syntax) |
|
| ~/.claude | Linting/validation only (shellcheck, JSON/YAML syntax, Python syntax) |
|
||||||
| Code repos | Full review via code-reviewer agent before user approval |
|
| Code repos | Full review via code-reviewer agent (Sonnet) before user approval |
|
||||||
|
|
||||||
|
### Gitea API Commands
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# List all PRs
|
||||||
|
curl -s -H "Authorization: token $(cat ~/.config/gitea-token)" \
|
||||||
|
"https://gitea-http.taildb3494.ts.net/api/v1/repos/will/claude-code/pulls?state=all"
|
||||||
|
|
||||||
|
# Close a PR (after rebase merge)
|
||||||
|
curl -s -X PATCH \
|
||||||
|
-H "Authorization: token $(cat ~/.config/gitea-token)" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{"state":"closed"}' \
|
||||||
|
"https://gitea-http.taildb3494.ts.net/api/v1/repos/will/claude-code/pulls/{PR_NUMBER}"
|
||||||
|
```
|
||||||
|
|
||||||
## Component Formats
|
## Component Formats
|
||||||
|
|
||||||
|
|||||||
88
automation/gitea-merge.sh
Executable file
88
automation/gitea-merge.sh
Executable file
@@ -0,0 +1,88 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Merge a feature branch with rebase, close PR, and cleanup
|
||||||
|
# Usage: gitea-merge.sh [branch-name]
|
||||||
|
# If no branch specified, uses current branch
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
GITEA_URL="https://gitea-http.taildb3494.ts.net"
|
||||||
|
REPO="will/claude-code"
|
||||||
|
TOKEN_FILE="$HOME/.config/gitea-token"
|
||||||
|
|
||||||
|
if [[ ! -f "$TOKEN_FILE" ]]; then
|
||||||
|
echo "Error: Gitea token not found at $TOKEN_FILE" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
TOKEN=$(cat "$TOKEN_FILE")
|
||||||
|
|
||||||
|
# Get branch to merge
|
||||||
|
BRANCH="${1:-$(git rev-parse --abbrev-ref HEAD)}"
|
||||||
|
|
||||||
|
if [[ "$BRANCH" == "main" ]]; then
|
||||||
|
echo "Error: Already on main, specify a feature branch" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Merging branch: $BRANCH"
|
||||||
|
|
||||||
|
# Find PR number for this branch
|
||||||
|
PR_NUMBER=$(curl -s -H "Authorization: token $TOKEN" \
|
||||||
|
"$GITEA_URL/api/v1/repos/$REPO/pulls?state=open" | \
|
||||||
|
python3 -c "
|
||||||
|
import sys, json
|
||||||
|
prs = json.load(sys.stdin)
|
||||||
|
for pr in prs:
|
||||||
|
if pr.get('head', {}).get('ref') == '$BRANCH':
|
||||||
|
print(pr['number'])
|
||||||
|
break
|
||||||
|
" 2>/dev/null || echo "")
|
||||||
|
|
||||||
|
# Stash any uncommitted changes
|
||||||
|
STASHED=false
|
||||||
|
if ! git diff --quiet || ! git diff --cached --quiet; then
|
||||||
|
echo "Stashing uncommitted changes..."
|
||||||
|
git stash
|
||||||
|
STASHED=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Checkout main and rebase
|
||||||
|
echo "Checking out main..."
|
||||||
|
git checkout main
|
||||||
|
git pull origin main
|
||||||
|
|
||||||
|
echo "Rebasing $BRANCH onto main..."
|
||||||
|
git rebase "$BRANCH"
|
||||||
|
|
||||||
|
echo "Pushing to origin..."
|
||||||
|
git push origin main
|
||||||
|
|
||||||
|
# Delete local branch
|
||||||
|
echo "Deleting local branch..."
|
||||||
|
git branch -d "$BRANCH" 2>/dev/null || true
|
||||||
|
|
||||||
|
# Delete remote branch
|
||||||
|
echo "Deleting remote branch..."
|
||||||
|
git push origin --delete "$BRANCH" 2>/dev/null || true
|
||||||
|
|
||||||
|
# Close PR if found
|
||||||
|
if [[ -n "$PR_NUMBER" ]]; then
|
||||||
|
echo "Closing PR #$PR_NUMBER..."
|
||||||
|
curl -s -X PATCH \
|
||||||
|
-H "Authorization: token $TOKEN" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{"state":"closed"}' \
|
||||||
|
"$GITEA_URL/api/v1/repos/$REPO/pulls/$PR_NUMBER" >/dev/null
|
||||||
|
echo "PR #$PR_NUMBER closed"
|
||||||
|
else
|
||||||
|
echo "No open PR found for branch $BRANCH"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Restore stashed changes
|
||||||
|
if [[ "$STASHED" == "true" ]]; then
|
||||||
|
echo "Restoring stashed changes..."
|
||||||
|
git stash pop
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "Done! Branch $BRANCH merged to main"
|
||||||
@@ -8,6 +8,12 @@
|
|||||||
"status": "active",
|
"status": "active",
|
||||||
"added": "2025-01-21"
|
"added": "2025-01-21"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "d4e5f6a7-8901-23de-f012-444444444444",
|
||||||
|
"instruction": "Use appropriate model for task: Haiku for simple extraction/formatting, Sonnet for code review/analysis, Opus for complex reasoning. Delegate to subagents with correct model.",
|
||||||
|
"status": "active",
|
||||||
|
"added": "2026-01-04"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "b2c3d4e5-6789-01bc-def0-222222222222",
|
"id": "b2c3d4e5-6789-01bc-def0-222222222222",
|
||||||
"instruction": "Git workflow: See CLAUDE.md for full process. Use rebase merges, not merge commits.",
|
"instruction": "Git workflow: See CLAUDE.md for full process. Use rebase merges, not merge commits.",
|
||||||
|
|||||||
Reference in New Issue
Block a user