---
name: gitea-tea
description: "Interact with a Gitea server using the tea CLI client"
version: 1.0.0
author: Hermes Agent
license: MIT
dependencies: []
platforms: [linux, macos, windows]
metadata:
  hermes:
    tags: [gitea, tea, cli, git, issue, pr, release]
    related_skills: []
---
# Gitea-Tea Skill

This skill provides a quick reference for using the `tea` CLI to interact with a Gitea server.

## Prerequisites

- `tea` installed (>=0.14). Install via:
  ```bash
  curl -L -o tea https://dl.gitea.com/tea/0.14.2/tea-linux-amd64
  chmod +x tea
  mv tea ~/.local/bin/  # or any directory in $PATH
  export PATH="$HOME/.local/bin:$PATH"
  ```
- A Gitea Personal Access Token (PAT) with appropriate scopes (repo, issues, etc.).

## Authentication

Add a login profile (once):

```bash
tea login add --name <profile-name> --url https://<gitea-host> --token <your-pat>
```

Example:
```bash
tea login add --name schroll --url https://git.cloud.schroll-it.de --token 248626ed18c608abb2d15785200554b2db79dfc2
```

Verify:
```bash
tea whoami
```

## Common Operations

### List repositories (owner/org)
```bash
tea repo list --owner <org-or-user>
```

### Create an issue
```bash
tea issue create --repo <owner>/<repo> --title "Issue title" \
    --description "Issue description" \
    --add-labels <label1>,<label2>   # optional, existing labels only
```

### Add a comment to an issue/PR
```bash
tea comments add --repo <owner>/<repo> <issue-number> "Your comment text"
```

### Edit an issue (e.g., add labels)
```bash
tea issue edit --repo <owner>/<repo> <issue-number> \
    --add-labels <label1>,<label2>   # use existing labels
```

### Close an issue
```bash
tea issue close --repo <owner>/<repo> <issue-number>
```

### List issues (filterable)
```bash
tea issue list --repo <owner>/<repo> --state open --label bug
```


### Retrieve PR details and diff
```bash
# Get PR details as JSON (includes URL, diffUrl, etc.)
tea pr <PR_NUMBER> --repo <owner>/<repo> --output json

# If you just need a summary, you can request specific fields:
tea pr <PR_NUMBER> --repo <owner>/<repo> --fields "index,title,state,author,updated,labels,diffUrl"

# The `diffUrl` field contains the raw patch/diff URL; you can fetch it with curl or your browser:
curl -L <DIFF_URL>
```

## Notes & Best Practices

- **Labels**: You may only use labels that already exist in the repository. To see available labels:
  ```bash
  tea label list --repo <owner>/<repo>
  ```
- **Non-interactive mode**: When scripting, tea may fall back to a saved login profile; ensure you have added a login with `tea login add`.
- **Error handling**: If you see `remote repository required`, double‑check the `--repo` argument format (`owner/repo`).
- **Security**: Never expose your PAT in logs or shared scripts; consider using `tea login helper setup` for Git credential storage if you need to push/pull over HTTPS.
- **PR files**: `tea pr files` is not a standalone subcommand; to list changed files, retrieve the PR's diff URL via `tea pr <NUMBER> --repo <owner>/<repo> --output json` and fetch it with `curl -L <diffUrl>`.
- **Pre-close check**: Before closing a PR, verify its state and mergeability via `tea pr <NUMBER> --repo <owner>/<repo> --output json` to avoid unintentionally discarding work.

## Advanced Operations

### List pull requests
```bash
tea pulls list --repo <owner>/<repo> --state open   # or closed/all
```

### Checkout a PR locally
```bash
tea pulls checkout <PR_NUMBER> --repo <owner>/<repo> --login <login-name>
# After checkout you are in detached HEAD; to make changes create a branch:
git checkout -b <branch-name>
```

### View PR details (summary)
```bash
tea pulls show <PR_NUMBER> --repo <owner>/<repo> --fields "index,title,state,author,updated,labels" --output json
```

### View PR diff
```bash
# Get the diff URL first
DIFF_URL=$(tea pulls show <PR_NUMBER> --repo <owner>/<repo> --fields diffUrl --output json | jq -r .diffUrl)
# Then fetch the diff
curl -L "$DIFF_URL"
```

### Add a comment to a PR
```bash
tea comments add --repo <owner>/<repo> <PR_NUMBER> "Your comment"
```

### Edit a PR (title/description)
```bash
tea pulls edit <PR_NUMBER> --repo <owner>/<repo> --title "New title" --description "New description"
```

### Merge a PR
```bash
tea pulls merge <PR_NUMBER> --repo <owner>/<repo> --merge-method merge   # or squash/rebase
```

### Close a PR (without merging)
```bash
tea pulls close <PR_NUMBER> --repo <owner>/<repo>
```

### Approve a PR
```bash
tea pulls approve <PR_NUMBER> --repo <owner>/<repo>
```

### Request changes (reject) on a PR
```bash
tea pulls reject <PR_NUMBER> --repo <owner>/<repo> --message "Please fix X"
```

### Notes
- Replace `<login-name>` with the profile you added via `tea login add`.
- If you omit `--login`, the default login is used.
- For scripting, you can use `--output json` and parse with `jq`.


## Example Session (from this conversation)

```bash
# Login
tea login add --name schroll --url https://git.cloud.schroll-it.de --token 248626ed18c608abb2d15785200554b2db79dfc2

# Create issue
tea issue create --repo Schroll-IT/BiteBudget --title "test Issue von Hermes"

# Add labels (existing ones: bug, testing, automerge)
tea issue edit --repo Schroll-IT/BiteBudget 241 --add-labels bug,testing,automerge

# Add comment
tea comments add --repo Schroll-IT/BiteBudget 241 "Automatischer Kommentar von Hermes: Labels gesetzt und Issue geschlossen."

# Close issue
tea issue close --repo Schroll-IT/BiteBudget 241
```

---

*Tip:* Keep this skill updated if new tea commands or Gitea API changes appear.