Add Gitea PR automation script
- Create automation/gitea-pr.sh for auto-creating PRs via Gitea API - Update CLAUDE.md with git workflow using the new script - Deprecate redundant git instructions in PA general-instructions.json - Token stored securely at ~/.config/gitea-token Usage: gitea-pr.sh "PR Title" "Description" 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
19
CLAUDE.md
19
CLAUDE.md
@@ -80,6 +80,25 @@ All agents MUST read and follow the processes defined in these files:
|
|||||||
- Session overrides in `state/sysadmin/session-autonomy.json`
|
- Session overrides in `state/sysadmin/session-autonomy.json`
|
||||||
- See `state/autonomy-levels.json` for level definitions
|
- See `state/autonomy-levels.json` for level definitions
|
||||||
|
|
||||||
|
### Git Workflow
|
||||||
|
This repo uses Gitea (not GitHub). Follow this workflow:
|
||||||
|
|
||||||
|
1. **Create feature branch**: `git checkout -b feature/descriptive-name`
|
||||||
|
2. **Commit work**: Make atomic commits with clear messages
|
||||||
|
3. **Rebase onto main**: `git rebase origin/main`
|
||||||
|
4. **Push branch**: `git push -u origin feature/branch-name`
|
||||||
|
5. **Create PR**: `~/.claude/automation/gitea-pr.sh "PR Title" "Description"`
|
||||||
|
6. **Merge with rebase** (after user approval):
|
||||||
|
```bash
|
||||||
|
git checkout main && git rebase feature/branch-name && git push
|
||||||
|
```
|
||||||
|
|
||||||
|
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`
|
||||||
|
|
||||||
## Component Formats
|
## Component Formats
|
||||||
|
|
||||||
| Component | Format | Location |
|
| Component | Format | Location |
|
||||||
|
|||||||
61
automation/gitea-pr.sh
Executable file
61
automation/gitea-pr.sh
Executable file
@@ -0,0 +1,61 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Create a PR in Gitea for the current branch
|
||||||
|
# Usage: gitea-pr.sh [title] [body]
|
||||||
|
|
||||||
|
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 current branch
|
||||||
|
BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
||||||
|
|
||||||
|
if [[ "$BRANCH" == "main" ]]; then
|
||||||
|
echo "Error: Cannot create PR from main branch" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Default title from branch name
|
||||||
|
TITLE="${1:-$BRANCH}"
|
||||||
|
BODY="${2:-Auto-generated PR for $BRANCH}"
|
||||||
|
|
||||||
|
# Create PR via API
|
||||||
|
RESPONSE=$(curl -s -X POST \
|
||||||
|
-H "Authorization: token $TOKEN" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{
|
||||||
|
\"title\": \"$TITLE\",
|
||||||
|
\"body\": \"$BODY\",
|
||||||
|
\"head\": \"$BRANCH\",
|
||||||
|
\"base\": \"main\"
|
||||||
|
}" \
|
||||||
|
"$GITEA_URL/api/v1/repos/$REPO/pulls")
|
||||||
|
|
||||||
|
# Extract PR URL or error
|
||||||
|
PR_URL=$(echo "$RESPONSE" | python3 -c "
|
||||||
|
import sys, json
|
||||||
|
d = json.load(sys.stdin)
|
||||||
|
if 'html_url' in d:
|
||||||
|
print(d['html_url'])
|
||||||
|
elif 'message' in d:
|
||||||
|
print(f\"Error: {d['message']}\", file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
print(f'Unexpected response: {d}', file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
" 2>&1)
|
||||||
|
|
||||||
|
if [[ $? -eq 0 ]]; then
|
||||||
|
echo "PR created: $PR_URL"
|
||||||
|
else
|
||||||
|
echo "$PR_URL" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
@@ -10,14 +10,14 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "b2c3d4e5-6789-01bc-def0-222222222222",
|
"id": "b2c3d4e5-6789-01bc-def0-222222222222",
|
||||||
"instruction": "Create a new git branch when working on new features (e.g., feature/descriptive-name). Commit work to the branch before rebasing and pushing.",
|
"instruction": "Git workflow: See CLAUDE.md for full process. Use rebase merges, not merge commits.",
|
||||||
"status": "active",
|
"status": "deprecated",
|
||||||
"added": "2026-01-03"
|
"added": "2026-01-03"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "c3d4e5f6-7890-12cd-ef01-333333333333",
|
"id": "c3d4e5f6-7890-12cd-ef01-333333333333",
|
||||||
"instruction": "The ~/.claude repo uses Gitea (not GitHub). After pushing a branch, create PR manually via Gitea web UI - gh CLI won't work.",
|
"instruction": "Git workflow: See CLAUDE.md for full process.",
|
||||||
"status": "active",
|
"status": "deprecated",
|
||||||
"added": "2026-01-03"
|
"added": "2026-01-03"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user