From 02f9cf7d8f16beda45b618fd44084865a58903e0 Mon Sep 17 00:00:00 2001 From: OpenCode Test Date: Sun, 4 Jan 2026 12:52:54 -0800 Subject: [PATCH] Add Gitea PR automation script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- CLAUDE.md | 19 ++++++ automation/gitea-pr.sh | 61 +++++++++++++++++++ .../general-instructions.json | 8 +-- 3 files changed, 84 insertions(+), 4 deletions(-) create mode 100755 automation/gitea-pr.sh diff --git a/CLAUDE.md b/CLAUDE.md index fde6bc5..b364e79 100644 --- a/CLAUDE.md +++ b/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` - 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 | Format | Location | diff --git a/automation/gitea-pr.sh b/automation/gitea-pr.sh new file mode 100755 index 0000000..f64f349 --- /dev/null +++ b/automation/gitea-pr.sh @@ -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 diff --git a/state/personal-assistant/general-instructions.json b/state/personal-assistant/general-instructions.json index c66585c..9b53d61 100644 --- a/state/personal-assistant/general-instructions.json +++ b/state/personal-assistant/general-instructions.json @@ -10,14 +10,14 @@ }, { "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.", - "status": "active", + "instruction": "Git workflow: See CLAUDE.md for full process. Use rebase merges, not merge commits.", + "status": "deprecated", "added": "2026-01-03" }, { "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.", - "status": "active", + "instruction": "Git workflow: See CLAUDE.md for full process.", + "status": "deprecated", "added": "2026-01-03" } ]