enhance!: rename tea to gt

The CLI becomes gitea-cli, invoked as gt.

- module path gitea.dev/cli, repository gitea.com/gitea/cli
- the binary, completions and man pages are named gt
- environment variables use the GITEA_CLI_ prefix
- the configuration directory, keyring service and git config keys use
  gitea-cli
- release archives, the Docker image and the snap are named gitea-cli
- version builds only from v* tags
- remove the 1.0 migration guide

Signed-off-by: bircni <[email protected]>
This commit is contained in:
bircni
2026-10-18 22:57:54 +02:00
parent 69c6d35608
commit 4a35b1577d
199 changed files with 690 additions and 1047 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
# The full repository name
repo: gitea/tea
repo: gitea/cli
# Service type (gitea or github)
service: gitea
+1 -1
View File
@@ -1,5 +1,5 @@
{
"name": "Tea DevContainer",
"name": "gitea-cli DevContainer",
"image": "mcr.microsoft.com/devcontainers/go:2.1-trixie",
"features": {
"ghcr.io/devcontainers/features/git-lfs:1.2.5": {}
+1 -1
View File
@@ -1,2 +1,2 @@
Dockerfile
tea
gt
+4 -4
View File
@@ -7,8 +7,8 @@ labels:
---
### describe your environment
- tea version used (`tea -v`):
- [ ] I also reproduced the issue [with the latest main build](https://dl.gitea.com/tea/main/)
- gt version used (`gt -v`):
- [ ] I also reproduced the issue [with the latest main build](https://dl.gitea.com/gitea-cli/main/)
- Gitea version used:
- [ ] the issue only occurred after updating gitea recently
- operating system:
@@ -17,10 +17,10 @@ labels:
- [ ] .ssh/config or .gitconfig host aliases in my git remotes
- [ ] ssh_agent or similar
- [ ] non-standard ports for gitea and/or ssh
- [ ] something else that's likely to interact badly with tea: ...
- [ ] something else that's likely to interact badly with gt: ...
Please provide the output of `git remote -v` (if the issue is related to tea not finding resources on Gitea):
Please provide the output of `git remote -v` (if the issue is related to gt not finding resources on Gitea):
```
```
+1 -1
View File
@@ -84,4 +84,4 @@ jobs:
linux/arm64
push: true
tags: |
gitea/tea:latest
gitea/gitea-cli:latest
+1 -1
View File
@@ -89,4 +89,4 @@ jobs:
linux/arm64
push: true
tags: |
gitea/tea:${{ env.VERSION }}
gitea/gitea-cli:${{ env.VERSION }}
+6 -6
View File
@@ -37,10 +37,10 @@ jobs:
runs-on: ubuntu-latest
env:
HTTP_PROXY: ""
GITEA_TEA_TEST_URL: "http://gitea:3000"
GITEA_TEA_TEST_TOKEN_FILE: /tmp/tea-ci-admin-token
GITEA_TEA_TEST_REVIEWER_TOKEN_FILE: /tmp/tea-ci-reviewer-token
GITEA_TEA_TEST_REPOSITORY_ROOT: /tmp/data
GITEA_CLI_TEST_URL: "http://gitea:3000"
GITEA_CLI_TEST_TOKEN_FILE: /tmp/gt-ci-admin-token
GITEA_CLI_TEST_REVIEWER_TOKEN_FILE: /tmp/gt-ci-reviewer-token
GITEA_CLI_TEST_REPOSITORY_ROOT: /tmp/data
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7
@@ -87,6 +87,6 @@ jobs:
&& echo "[server]" >> /tmp/conf/app.ini
&& echo "ROOT_URL = http://gitea:3000" >> /tmp/conf/app.ini
&& gitea migrate -c /tmp/conf/app.ini
&& gitea admin user create --username=integration --password=tea-local-integration-pass [email protected] --admin=true --must-change-password=false -c /tmp/conf/app.ini
&& gitea admin user create --username=tea-reviewer --password=tea-local-reviewer-pass --email=tea[email protected] --must-change-password=false -c /tmp/conf/app.ini
&& gitea admin user create --username=integration --password=gt-local-integration-pass [email protected] --admin=true --must-change-password=false -c /tmp/conf/app.ini
&& gitea admin user create --username=gt-reviewer --password=gt-local-reviewer-pass --email=g[email protected] --must-change-password=false -c /tmp/conf/app.ini
&& gitea web -c /tmp/conf/app.ini
+3 -3
View File
@@ -1,4 +1,4 @@
/tea
/gt
/gitea-vet
/gitea-vet.exe
@@ -17,8 +17,8 @@ dist/
docs/generated/
# Release docs archive produced by `make docs-archive` / goreleaser before hooks
tea-*-docs.tar.xz
tea-*-docs.tar.xz.sha256
gitea-cli-*-docs.tar.xz
gitea-cli-*-docs.tar.xz.sha256
# Nix-specific
.direnv/
+7 -5
View File
@@ -1,13 +1,15 @@
version: 2
project_name: gitea-cli
before:
hooks:
- go mod tidy
# Regenerate references/man/completions, then pack a versioned docs
# archive outside dist/ (goreleaser requires dist/ empty after hooks).
# tea-{{ .Version }}-docs.tar.xz is picked up by release/publisher/
# gitea-cli-{{ .Version }}-docs.tar.xz is picked up by release/publisher/
# checksum ./**.xz globs alongside binary .xz artifacts.
- make docs-archive DOCS_ARCHIVE=tea-{{ .Version }}-docs.tar.xz
- make docs-archive DOCS_ARCHIVE=gitea-cli-{{ .Version }}-docs.tar.xz
builds:
- env:
@@ -63,7 +65,7 @@ builds:
flags:
- -trimpath
ldflags:
- -s -w -X "gitea.dev/tea/internal/version.Version={{ trimprefix .Summary "v" }}" -X "gitea.dev/tea/internal/version.Tags="
- -s -w -X "gitea.dev/cli/internal/version.Version={{ trimprefix .Summary "v" }}" -X "gitea.dev/cli/internal/version.Tags="
binary: >-
{{ .ProjectName }}-
{{- .Version }}-
@@ -112,7 +114,7 @@ publishers:
extra_files:
- glob: ./**.xz
- glob: ./**.sha256
cmd: sh scripts/upload-r2.sh {{ abs .ArtifactPath }} tea/{{ .Version }}/{{ .ArtifactName }}
cmd: sh scripts/upload-r2.sh {{ abs .ArtifactPath }} gitea-cli/{{ .Version }}/{{ .ArtifactName }}
env:
- R2_ENDPOINT={{ index .Env "R2_ENDPOINT" }}
- R2_BUCKET={{ index .Env "R2_BUCKET" }}
@@ -150,7 +152,7 @@ gitea_urls:
release:
# Includes per-platform binary .xz artifacts and the docs archive
# tea-<version>-docs.tar.xz (references, man pages, bash/zsh/fish/powershell
# gitea-cli-<version>-docs.tar.xz (references, man pages, bash/zsh/fish/powershell
# completions) produced by the before.hooks docs-archive step.
extra_files:
- glob: ./**.xz
+19 -19
View File
@@ -18,7 +18,7 @@
## Introduction
This document explains how to contribute changes to TEA.
This document explains how to contribute changes to gitea-cli.
Sensitive security-related issues should be reported to
[[email protected]](mailto:[email protected]).
@@ -29,20 +29,20 @@ For configuring IDE or code editor to develop Gitea see [IDE and code editor con
Please search the issues on the issue tracker with a variety of keywords
to ensure your bug is not already reported.
If unique, [open an issue](https://gitea.com/gitea/tea/issues/new).
If unique, [open an issue](https://gitea.com/gitea/cli/issues/new).
Please write clear, concise instructions so we can reproduce the behavior—
even if it seems obvious. The more detailed and specific you are,
the faster we can fix the issue. Check out [How to Report Bugs
Effectively](http://www.chiark.greenend.org.uk/~sgtatham/bugs.html).
Please be kind, remember that TEA comes at no cost to you, and you're
Please be kind, remember that gitea-cli comes at no cost to you, and you're
getting free help.
## Discuss your design
The project welcomes submissions. If you want to change or add something,
please let everyone know what you're working on—[file an issue](https://gitea.com/gitea/tea/issues/new)!
please let everyone know what you're working on—[file an issue](https://gitea.com/gitea/cli/issues/new)!
Significant changes must go through the change proposal process
before they can be accepted. To create a proposal, file an issue with
your proposed changes documented, and make sure to note in the title
@@ -57,29 +57,29 @@ high-level discussions.
## Testing redux
Before sending code out for review, run the unit tests with `make test`.
Since TEA is an cli tool it should be obvious to test your feature locally first.
Since gitea-cli is an cli tool it should be obvious to test your feature locally first.
Tests live beside the packages they exercise. `make integration-test` runs the
`TestGitea*` tests against a disposable Gitea instance with an administrator
account named `integration` and a reviewer named `tea-reviewer`. Never point
account named `integration` and a reviewer named `gt-reviewer`. Never point
these tests at a production instance: they create and delete resources.
```sh
GITEA_TEA_TEST_URL=http://127.0.0.1:3000 \
GITEA_TEA_TEST_TOKEN_FILE=/private/path/admin-token \
GITEA_TEA_TEST_REVIEWER_TOKEN_FILE=/private/path/reviewer-token \
GITEA_CLI_TEST_URL=http://127.0.0.1:3000 \
GITEA_CLI_TEST_TOKEN_FILE=/private/path/admin-token \
GITEA_CLI_TEST_REVIEWER_TOKEN_FILE=/private/path/reviewer-token \
make integration-test
```
Token files contain scoped PATs for their accounts and should be `0600`;
`scripts/integration-tokens.py` creates them for the CI accounts. Optional
coverage is enabled by `GITEA_TEA_TEST_REPOSITORY_ROOT` (the server's repository
coverage is enabled by `GITEA_CLI_TEST_REPOSITORY_ROOT` (the server's repository
root, with `[repository] IMPORT_LOCAL_PATHS = true`, for migration) and
`GITEA_TEA_TEST_SSH_ENDPOINT` (an SSH clone endpoint).
`GITEA_CLI_TEST_SSH_ENDPOINT` (an SSH clone endpoint).
## Code review
Changes to TEA must be reviewed before they are accepted—no matter who
Changes to gitea-cli must be reviewed before they are accepted—no matter who
makes the change, even if they are an owner or a maintainer. We use Gitea's
pull request & review workflow to do that. Gitea ensure every PR is reviewed by at least 2 maintainers.
@@ -100,8 +100,8 @@ Some of the key points:
### Commands
Use explicit singular noun/verb commands, such as `tea issue list` and
`tea pr create`. Bare command groups show help. Commands validate input, collect
Use explicit singular noun/verb commands, such as `gt issue list` and
`gt pr create`. Bare command groups show help. Commands validate input, collect
missing fields when the shared prompting policy permits it, invoke services, and
render results through injected streams. Destructive commands require confirmation
or `--yes`; `--no-input` disables implicit interaction. JSON results go to stdout;
@@ -113,15 +113,15 @@ diagnostics and prompts go to stderr. Lists register `--limit`/`--page` with
- `internal/app`: Cobra commands and application dependency construction.
- `internal/services`: typed workflows over `gitea.dev/sdk`, independent of CLI flags
and terminal I/O, including pagination policy. Services map SDK types to tea's
and terminal I/O, including pagination policy. Services map SDK types to gt's
output types; requests the SDK cannot make yet go through the raw helpers in
`raw.go`, each marked `TODO(sdk)` with the missing SDK piece.
- `internal/settings`: split configuration, validation, persistence, target resolution,
and remote URL parsing.
- `internal/auth`: secure credentials and OAuth lifecycle.
- `internal/transport`: the tea HTTP client shared by the SDK and raw requests: TLS,
- `internal/transport`: the gt HTTP client shared by the SDK and raw requests: TLS,
timeouts, User-Agent, `--debug`, retries, token, Sudo and SSH-signature
authentication, and sanitised API errors. Its raw requests serve `tea api`, signed
authentication, and sanitised API errors. Its raw requests serve `gt api`, signed
downloads and log streaming.
- `internal/git`: repository discovery and cancellable Git subprocesses.
- `internal/terminal`: streams, input, editor, browser, and rendering.
@@ -141,7 +141,7 @@ import (
"encoding/json"
"fmt"
"gitea.dev/tea/internal/services"
"gitea.dev/cli/internal/services"
"github.com/foo/bar"
"gopkg.io/baz.v1"
)
@@ -219,7 +219,7 @@ and lead the development of Gitea.
## Versions
tea has the `master` branch as a tip branch and has version branches
gt has the `master` branch as a tip branch and has version branches
such as `release/v0.9`. `release/v0.9` is a release branch and we will
tag `v0.9.0` for binary download. If `v0.9.0` has bugs, we will accept
pull requests on the `release/v0.9` branch and publish a `v0.9.1` tag,
+3 -3
View File
@@ -1,12 +1,12 @@
FROM docker.io/chainguard/go:latest AS build
COPY . /build/
WORKDIR /build
RUN make build && mkdir -p /app/.config/tea
RUN make build && mkdir -p /app/.config/gitea-cli
FROM docker.io/chainguard/busybox:latest-glibc
COPY --from=build /build/tea /bin/tea
COPY --from=build /build/gt /bin/gt
COPY --from=build --chown=65532:65532 /app /app
VOLUME [ "/app" ]
ENV HOME="/app"
ENTRYPOINT ["/bin/sh", "-c"]
CMD [ "tea" ]
CMD [ "gt" ]
+16 -16
View File
@@ -12,19 +12,19 @@ GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/v2/cmd/golangci-lint@
ifneq ($(DRONE_TAG),)
VERSION ?= $(subst v,,$(DRONE_TAG))
TEA_VERSION ?= $(VERSION)
GITEA_CLI_VERSION ?= $(VERSION)
else
ifneq ($(DRONE_BRANCH),)
VERSION ?= $(subst release/v,,$(DRONE_BRANCH))
else
VERSION ?= main
endif
TEA_VERSION ?= $(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//')
GITEA_CLI_VERSION ?= $(shell git describe --tags --match 'v*' --always | sed 's/-/+/' | sed 's/^v//')
endif
TEA_VERSION_TAG ?= $(shell sed 's/+/_/' <<< $(TEA_VERSION))
GITEA_CLI_VERSION_TAG ?= $(shell sed 's/+/_/' <<< $(GITEA_CLI_VERSION))
TAGS ?=
LDFLAGS := -X "gitea.dev/tea/internal/version.Version=$(TEA_VERSION)" -X "gitea.dev/tea/internal/version.Tags=$(TAGS)" -s -w
LDFLAGS := -X "gitea.dev/cli/internal/version.Version=$(GITEA_CLI_VERSION)" -X "gitea.dev/cli/internal/version.Tags=$(TAGS)" -s -w
# override to allow passing additional goflags via make CLI
override GOFLAGS := $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)'
@@ -35,10 +35,10 @@ SOURCES ?= $(shell find . -name "*.go" -type f)
# OS specific vars.
ifeq ($(OS), Windows_NT)
EXECUTABLE := tea.exe
EXECUTABLE := gt.exe
VET_TOOL := gitea-vet.exe
else
EXECUTABLE := tea
EXECUTABLE := gt
VET_TOOL := gitea-vet
endif
@@ -88,7 +88,7 @@ docs:
# Versioned docs archive for release uploads (references, man pages, completions).
# Keep the artifact outside dist/: goreleaser requires dist/ empty after before hooks.
# The .tar.xz suffix matches existing release/publisher/checksum ./**.xz globs.
DOCS_ARCHIVE ?= tea-$(TEA_VERSION_TAG)-docs.tar.xz
DOCS_ARCHIVE ?= gitea-cli-$(GITEA_CLI_VERSION_TAG)-docs.tar.xz
.PHONY: docs-archive
docs-archive: docs
@@ -106,13 +106,13 @@ install-docs: docs
install -d "$(DESTDIR)$(PREFIX)/share/man/man1"
install -m 644 docs/generated/man/*.1 "$(DESTDIR)$(PREFIX)/share/man/man1/"
install -d "$(DESTDIR)$(PREFIX)/share/bash-completion/completions"
install -m 644 docs/generated/completion/tea.bash "$(DESTDIR)$(PREFIX)/share/bash-completion/completions/tea"
install -m 644 docs/generated/completion/gt.bash "$(DESTDIR)$(PREFIX)/share/bash-completion/completions/gt"
install -d "$(DESTDIR)$(PREFIX)/share/zsh/site-functions"
install -m 644 docs/generated/completion/_tea "$(DESTDIR)$(PREFIX)/share/zsh/site-functions/_tea"
install -m 644 docs/generated/completion/_gt "$(DESTDIR)$(PREFIX)/share/zsh/site-functions/_gt"
install -d "$(DESTDIR)$(PREFIX)/share/fish/vendor_completions.d"
install -m 644 docs/generated/completion/tea.fish "$(DESTDIR)$(PREFIX)/share/fish/vendor_completions.d/tea.fish"
install -d "$(DESTDIR)$(PREFIX)/share/powershell/Modules/tea"
install -m 644 docs/generated/completion/tea.ps1 "$(DESTDIR)$(PREFIX)/share/powershell/Modules/tea/tea.ps1"
install -m 644 docs/generated/completion/gt.fish "$(DESTDIR)$(PREFIX)/share/fish/vendor_completions.d/gt.fish"
install -d "$(DESTDIR)$(PREFIX)/share/powershell/Modules/gt"
install -m 644 docs/generated/completion/gt.ps1 "$(DESTDIR)$(PREFIX)/share/powershell/Modules/gt/gt.ps1"
.PHONY: unit-test
unit-test:
@@ -120,9 +120,9 @@ unit-test:
.PHONY: integration-test
integration-test:
@test -n "$$GITEA_TEA_TEST_URL" || { echo 'Set GITEA_TEA_TEST_URL to a disposable Gitea instance' >&2; exit 1; }
@test -r "$$GITEA_TEA_TEST_TOKEN_FILE" || { echo 'Set GITEA_TEA_TEST_TOKEN_FILE to a readable administrator token file' >&2; exit 1; }
@test -r "$$GITEA_TEA_TEST_REVIEWER_TOKEN_FILE" || { echo 'Set GITEA_TEA_TEST_REVIEWER_TOKEN_FILE to a readable reviewer token file' >&2; exit 1; }
@test -n "$$GITEA_CLI_TEST_URL" || { echo 'Set GITEA_CLI_TEST_URL to a disposable Gitea instance' >&2; exit 1; }
@test -r "$$GITEA_CLI_TEST_TOKEN_FILE" || { echo 'Set GITEA_CLI_TEST_TOKEN_FILE to a readable administrator token file' >&2; exit 1; }
@test -r "$$GITEA_CLI_TEST_REVIEWER_TOKEN_FILE" || { echo 'Set GITEA_CLI_TEST_REVIEWER_TOKEN_FILE to a readable reviewer token file' >&2; exit 1; }
$(GO) test -count=1 -race -run '^TestGitea' $(PACKAGES)
.PHONY: test
@@ -157,4 +157,4 @@ $(EXECUTABLE): $(SOURCES)
.PHONY: build-image
build-image:
docker build --build-arg VERSION=$(TEA_VERSION) -t gitea/tea:$(TEA_VERSION_TAG) .
docker build --build-arg VERSION=$(GITEA_CLI_VERSION) -t gitea/gitea-cli:$(GITEA_CLI_VERSION_TAG) .
+37 -38
View File
@@ -1,57 +1,56 @@
# <img alt='tea logo' src='https://gitea.com/repo-avatars/550-80a3a8c2ab0e2c2d69f296b7f8582485' height="40"/> *T E A*
# <img alt='gt logo' src='https://gitea.com/repo-avatars/550-80a3a8c2ab0e2c2d69f296b7f8582485' height="40"/> *T E A*
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![Release](https://raster.shields.io/badge/dynamic/json.svg?label=release&url=https://gitea.com/api/v1/repos/gitea/tea/releases&query=$[0].tag_name)](https://gitea.com/gitea/tea/releases)
[![Release](https://raster.shields.io/badge/dynamic/json.svg?label=release&url=https://gitea.com/api/v1/repos/gitea/cli/releases&query=$[0].tag_name)](https://gitea.com/gitea/cli/releases)
[![Join the chat at https://img.shields.io/discord/322538954119184384.svg](https://img.shields.io/discord/322538954119184384.svg)](https://discord.gg/Gitea)
[![Go Report Card](https://goreportcard.com/badge/gitea.dev/tea)](https://goreportcard.com/report/gitea.dev/tea) [![GoDoc](https://pkg.go.dev/badge/gitea.dev/tea?status.svg)](https://godoc.org/gitea.dev/tea)
![Tea Release Status](https://gitea.com/gitea/tea/actions/workflows/release-nightly.yml/badge.svg)
[![Go Report Card](https://goreportcard.com/badge/gitea.dev/cli)](https://goreportcard.com/report/gitea.dev/cli) [![GoDoc](https://pkg.go.dev/badge/gitea.dev/cli?status.svg)](https://godoc.org/gitea.dev/cli)
![gitea-cli Release Status](https://gitea.com/gitea/cli/actions/workflows/release-nightly.yml/badge.svg)
## The official CLI for Gitea
Tea manages repositories, issues, pull requests, releases, and other Gitea resources
gitea-cli manages repositories, issues, pull requests, releases, and other Gitea resources
with explicit commands suitable for local development and CI.
```sh
tea auth login --host https://gitea.example.org --with-token < token-file
tea issue list --repo owner/repository
tea pr view 123 --repo owner/repository --json
tea alias set bugs 'issue list --label bug'
tea help
gt auth login --host https://gitea.example.org --with-token < token-file
gt issue list --repo owner/repository
gt pr view 123 --repo owner/repository --json
gt alias set bugs 'issue list --label bug'
gt help
```
tea 1.0 is a breaking release: it requires Gitea 28 or newer, commands, flags and
gt 1.0 is a breaking release: it requires Gitea 28 or newer, commands, flags and
output formats changed, it uses separate `config.yml` and `hosts.yml` files, and it
requires fresh authentication.
Existing combined configuration files are left untouched; archive the old file or
choose an isolated `TEA_CONFIG_DIR` before setup. See
[Migrating to tea 1.0](docs/migration-1.0.md) for the old-to-new mapping.
Run `tea --help` or `tea <command> --help` for supported commands and flags; the
choose an isolated `GITEA_CLI_CONFIG_DIR` before setup.
Run `gt --help` or `gt <command> --help` for supported commands and flags; the
full reference, man pages, and shell completions ship in each release's docs archive.
Credentials use the operating-system keyring by default; explicitly
select `--credential-store file` when private file storage is needed. For CI,
supply `GITEA_TOKEN` and its instance through `TEA_HOST` or `GITEA_INSTANCE_URL`;
supply `GITEA_TOKEN` and its instance through `GITEA_CLI_HOST` or `GITEA_INSTANCE_URL`;
environment credentials are never persisted.
## Installation
There are different ways to get `tea`:
There are different ways to get `gt`:
1. Install via your system package manager:
- macOS via `brew` (official):
```sh
brew install tea
brew install gt
```
- arch linux ([tea](https://archlinux.org/packages/extra/x86_64/tea/), thirdparty)
- alpine linux ([tea](https://pkgs.alpinelinux.org/packages?name=tea&branch=edge), thirdparty)
- Windows via `MSYS2` ([tea](https://packages.msys2.org/base/mingw-w64-tea), thirdparty)
- arch linux ([gt](https://archlinux.org/packages/extra/x86_64/gt/), thirdparty)
- alpine linux ([gt](https://pkgs.alpinelinux.org/packages?name=gt&branch=edge), thirdparty)
- Windows via `MSYS2` ([gt](https://packages.msys2.org/base/mingw-w64-gt), thirdparty)
2. Use the prebuilt binaries from [dl.gitea.com](https://dl.gitea.com/tea/)
2. Use the prebuilt binaries from [dl.gitea.com](https://dl.gitea.com/gitea-cli/)
3. Install from source: [see *Compilation*](#compilation)
4. Docker: [Tea at docker hub](https://hub.docker.com/r/gitea/tea)
4. Docker: [gitea-cli at docker hub](https://hub.docker.com/r/gitea/gitea-cli)
### Log in to Gitea from tea
### Log in to Gitea from gt
Gitea can use many different authentication schemes, and not every authentication method will work with every Gitea deployment. When you are a Gitea instance administrator you can tweak your settings to fit your use case. For the method that is most likely to work with any Gitea deployment use the following steps:
@@ -61,43 +60,43 @@ Gitea can use many different authentication schemes, and not every authenticatio
3. In your "user settings", generate an application token with at least **user read** permissions. If you want to do anything useful with the token add additional permissions/scopes.
4. Save the token in a private file and run `tea auth login --host https://your-instance --with-token < token-file`. Credentials use the operating-system keyring by default.
4. Save the token in a private file and run `gt auth login --host https://your-instance --with-token < token-file`. Credentials use the operating-system keyring by default.
You should now be logged in to your gitea instance from tea.
You should now be logged in to your gitea instance from gt.
Alternatively, `tea auth login --host https://your-instance --oauth` authorizes tea in your browser. OAuth may not be available on all Gitea deployments, and needs a browser on the machine running tea.
Alternatively, `gt auth login --host https://your-instance --oauth` authorizes gt in your browser. OAuth may not be available on all Gitea deployments, and needs a browser on the machine running gt.
### Shell completion
If you installed from source or the package does not provide the completions with it you can add them yourself with `tea completion <shell>` command. To generate the completions run one of the following commands depending on your shell.
If you installed from source or the package does not provide the completions with it you can add them yourself with `gt completion <shell>` command. To generate the completions run one of the following commands depending on your shell.
```shell
# .bashrc
source <(tea completion bash)
source <(gt completion bash)
# .zshrc
source <(tea completion zsh)
source <(gt completion zsh)
# fish
tea completion fish > ~/.config/fish/completions/tea.fish
gt completion fish > ~/.config/fish/completions/gt.fish
# PowerShell profile
tea completion powershell | Out-String | Invoke-Expression
gt completion powershell | Out-String | Invoke-Expression
```
### Man Page
The hidden command `tea man` can be used to generate the `tea` man page.
The hidden command `gt man` can be used to generate the `gt` man page.
```shell
# for bash or zsh
man <(tea man)
man <(gt man)
# for fish
man (tea man | psub)
man (gt man | psub)
# write man page to a file
tea man --output-file ./tea.man
gt man --output-file ./gt.man
```
## Compilation
@@ -106,8 +105,8 @@ Make sure you have a current Go version installed (1.27 or newer).
- To compile the source yourself with the recommended flags & tags:
```sh
git clone https://gitea.com/gitea/tea.git # or: tea repo clone https://gitea.com/gitea/tea ;)
cd tea
git clone https://gitea.com/gitea/cli.git # or: gt repo clone https://gitea.com/gitea/cli ;)
cd cli
make
```
Note that GNU Make (gmake on OpenBSD) is required.
@@ -119,7 +118,7 @@ Make sure you have a current Go version installed (1.27 or newer).
- For a quick installation without `git` & `make`, set $version and exec:
```sh
go install gitea.dev/tea@${version}
go install gitea.dev/cli@${version}
```
## Contributing
+11 -11
View File
@@ -3,28 +3,28 @@
Select a repository explicitly for scripts and supply a token scoped to its instance:
```sh
export TEA_HOST=https://gitea.example.org
export TEA_REPO=owner/repository
export GITEA_CLI_HOST=https://gitea.example.org
export GITEA_CLI_REPO=owner/repository
# Supply GITEA_TOKEN through your CI secret environment.
tea workflow list --no-input --json
tea workflow view deploy.yml --no-input --json
tea workflow run deploy.yml --ref main --field env=staging --field version=1.2.3 --no-input
tea workflow disable deploy.yml --yes --no-input
tea workflow enable deploy.yml --no-input
gt workflow list --no-input --json
gt workflow view deploy.yml --no-input --json
gt workflow run deploy.yml --ref main --field env=staging --field version=1.2.3 --no-input
gt workflow disable deploy.yml --yes --no-input
gt workflow enable deploy.yml --no-input
```
Workflow dispatch requires a `workflow_dispatch` trigger in the workflow. Dispatch
and watching are separate commands; find the run with `tea run list`, then use
`tea run watch RUN_ID --timeout 10m --no-input`. Unsuccessful completed runs return
and watching are separate commands; find the run with `gt run list`, then use
`gt run watch RUN_ID --timeout 10m --no-input`. Unsuccessful completed runs return
a nonzero exit code.
For an explicitly authorized merge in CI:
```sh
tea pr merge 123 --repo owner/repository --method rebase --no-input
gt pr merge 123 --repo owner/repository --method rebase --no-input
```
Keep credentials in the secret environment or credential store. Never write a token
into `config.yml` or `hosts.yml`. Run `tea help <command>`, or see the command
into `config.yml` or `hosts.yml`. Run `gt help <command>`, or see the command
reference in each release's docs archive, for supported flags and the
[README](../README.md) for fresh authentication.
-358
View File
@@ -1,358 +0,0 @@
# Migrating to tea 1.0
tea 1.0 rebuilds the CLI around explicit, singular `noun verb` commands (similar
to GitHub's `gh`), a split configuration, and per-instance accounts. There are no
compatibility aliases: old command names, plural groups and most short flags are
gone, and scripts need updating. This guide lists what changed and what to use
instead.
Quick checklist:
1. Make sure your instances run Gitea 28 or newer
([Server requirements](#server-requirements)).
2. Move the old configuration away, or point tea 1.0 at a new directory
([Configuration](#old-configuration-file)).
3. Log in again ([Logging in](#logging-in-again)).
4. Replace the old `!tea login helper` Git credential entries
([Git credential helper](#git-credential-helper)).
5. Regenerate shell completions ([Shell completion](#shell-completion)).
6. Update scripts: [global flags](#global-flags), [commands](#renamed-commands),
[arguments](#changed-positional-arguments) and [output](#output-formats).
Run `tea <command> --help` for the full flag list of any command.
## Server requirements
Requires Gitea 28 or newer. tea no longer probes `/api/v1/version` or
`/swagger.v1.json` to adapt to older servers: on an older instance, commands
that need a newer endpoint fail with the server's HTTP error instead of a
"not supported" message.
## Configuration and login
### Old configuration file
Older releases kept logins and preferences in one file, `config.yml` in the `tea`
directory under the platform configuration directory (`~/.config/tea/config.yml`
on Linux; very old releases used `~/.tea/tea.yml`). tea 1.0 stores preferences in
`config.yml` and instances and accounts in `hosts.yml`, in the same directory by
default; `tea config path` prints both paths. When it finds an old-format file it
stops with:
```text
legacy tea configuration: archive the old config.yml or select a separate TEA_CONFIG_DIR, then run tea auth login; existing files have not been changed
```
Nothing is imported automatically. Either archive the old file:
```sh
mv ~/.config/tea/config.yml ~/.config/tea/config.yml.old # adjust the path on macOS and Windows
```
or keep it and give tea 1.0 its own directory with `TEA_CONFIG_DIR`. Do not run
an old tea against a directory written by tea 1.0: it reads the new `config.yml`
as an empty login list and overwrites it on its next save.
`tea config list` shows effective preferences. Old settings map as follows:
| Old `config.yml` | tea 1.0 |
|---|---|
| `preferences.editor: true` | `tea config set editor "<command>"` (a command, not a switch) |
| `preferences.flag_defaults.remote` | `tea config set remote <name>` |
| login `default: true` | `tea config set default_host <url>` |
| login `insecure`, `ssh_host` | `tea config set --host <url> insecure true`, `... ssh_host <host[:port]>` |
| login `ssh_key`, `ssh_agent`, `ssh_certificate_principal`, `ssh_key_agent_pub` | `tea config set --host <url> --user <name> ssh_key …` (also `ssh_agent`, `ssh_certificate_principal`, `ssh_key_fingerprint`) |
### Logging in again
Accounts are identified by instance URL and username instead of a login name.
`tea auth login --host <url>` replaces `tea login add`:
| Old | tea 1.0 |
|---|---|
| `tea login add --url URL --token TOKEN` | `tea auth login --host URL --with-token < token-file` (the token is read from stdin) |
| `tea login add --oauth` | `tea auth login --host URL --oauth` |
| `tea login add --ssh-key PATH` / `-s` | `tea auth login --host URL --ssh-key PATH` |
| `--ssh-agent-key` / `-a`, `--ssh-agent-principal` / `-c` | same long flags, no shorthands |
| `--insecure` / `-i` | `--insecure` |
| `--user`, `--password`, `--otp`, `--scopes` (create a token with basic auth) | removed: create a token in the web UI (Settings → Applications) or use `--oauth` |
| `--name`, `--no-version-check` | removed |
| `--redirect-url` | removed: OAuth always listens on a random loopback port |
| `--git-credentials` / `--helper` / `-j` | `tea auth setup-git --host URL` |
Token logins of the old release kept the token in plain text under
`logins[].token` in the old `config.yml`, so you can pipe it straight into
`tea auth login --with-token` instead of creating a new one.
Credentials go to the operating-system keyring (service `tea-cli-v2`). Pass
`--credential-store file` to store them in private files under the configuration
directory instead. The old release's OAuth tokens (keyring service `tea-cli`, and
`credentials.json` in the old configuration directory) are not read; delete them once you
have logged in again.
Managing accounts:
| Old | tea 1.0 |
|---|---|
| `tea login list`, `tea login status`, `tea whoami` | `tea auth status` (`--verify` checks each credential) |
| `tea login default NAME` | `tea config set default_host URL`, and `tea auth switch USER --host URL` for the active account |
| `tea login edit` | `tea config set --host URL <key> <value>` |
| `tea login delete NAME`, `tea logout NAME` | `tea auth logout --host URL [--user USER]` |
| `tea login oauth-refresh` | `tea auth refresh` |
### Environment variables
| Variable | tea 1.0 |
|---|---|
| `GITEA_TOKEN`, `GITEA_INSTANCE_URL` | supported; `TEA_HOST` is an alternative to `GITEA_INSTANCE_URL` |
| `GITEA_INSTANCE_INSECURE`, `GITEA_INSTANCE_SSH_HOST` | supported |
| `GH_TOKEN` | no longer read: use `GITEA_TOKEN` |
| `GITEA_SERVER_URL`, `GITEA_SERVER_TOKEN`, `GITEA_SERVER_USER`, `GITEA_SERVER_PASSWORD`, `GITEA_SERVER_OTP`, `GITEA_SCOPES` | removed with `tea login add` |
New variables: `TEA_CONFIG_DIR`, `TEA_HOST`, `TEA_USER`, `TEA_REPO`, `TEA_EDITOR`,
`TEA_PAGER` and `TEA_COLOR`; see `tea config --help`. Environment credentials are
never written to disk.
### Git credential helper
`tea login helper setup` and `tea login add --git-credentials` wrote two entries
to `~/.gitconfig` for each instance: an empty `credential.<url>.helper` and
`!tea login helper`. tea 1.0 has no `login` command, so Git now gets an error
from that helper and falls back to prompting. Remove both entries, then register
the new helper:
```sh
git config --global --get-all credential.https://gitea.example.org.helper
git config --global --unset-all credential.https://gitea.example.org.helper '^!tea login helper$'
git config --global --unset-all credential.https://gitea.example.org.helper '^$'
tea auth setup-git --host https://gitea.example.org
```
`tea repo clone`, `tea pr checkout`, `tea pr clean`, `tea repo sync` and
`tea pr create --agit` authenticate Git without any helper; `tea auth setup-git`
is only needed for plain `git` commands. Add `--local` to configure only the
current repository.
## Global flags
| Old | tea 1.0 |
|---|---|
| `--repo` / `-r` | `--repo` / `-R` |
| `--remote` / `-R` | `--remote` (no shorthand) |
| `--login` / `-l` | `--host URL`, plus `--user NAME` when the instance has several accounts |
| `--output` / `-o`, `--fields` / `-f` | `--json [fields]` and `--jq <expression>` |
| `--debug` / `--vvv` | `--debug` |
| `--confirm` / `-y`, `--force` / `-f` on destructive commands | `--yes` |
`-R` now means `--repo`: `tea issue list -R origin` fails with
`invalid repository URL` instead of selecting the `origin` remote. Use
`--remote origin`.
New global flags: `--no-input` disables prompts, editors and browsers, `--yes`
accepts confirmations, `--cwd` selects the directory used for repository
discovery, and `--sudo USER` acts as another user (administrators only).
## Renamed commands
All command groups are singular, and the built-in aliases (`ls`, `rm`, `c`, `e`,
`i`, `ms`, `co`, `lgtm`, …) are gone. `tea alias set NAME EXPANSION` defines your
own top-level shortcuts, for example `tea alias set co 'pr checkout'`; aliases
for subcommands such as `issue ls` are not possible.
Top-level groups:
| Old | tea 1.0 |
|---|---|
| `issues`, `issue`, `i` | `issue` |
| `pulls`, `pull`, `pr` | `pr` |
| `labels` | `label` |
| `milestones`, `ms` | `milestone` |
| `releases`, `r` | `release` |
| `times`, `t` | `time` |
| `organizations`, `org` | `org` |
| `repos` | `repo` |
| `branches`, `b` | `branch` |
| `actions secrets` | `secret` |
| `actions variables` | `variable` |
| `actions runs` | `run` |
| `actions workflows` | `workflow` |
| `webhooks`, `hooks` | `webhook` |
| `comments`, `c` | `issue comment` / `pr comment` |
| `notifications`, `n` | `notification` |
| `ssh-keys` | `ssh-key` |
| `admin users`, `admin u` | `admin user` |
| `logins`, `login`, `logout`, `whoami` | `auth` (see [Logging in](#logging-in-again)) |
| `clone`, `C` | `repo clone` |
| `open`, `o` | removed (see [Removed features](#removed-features)) |
Groups no longer run a default action: `tea issues` listed issues and
`tea issues 5` showed issue 5; use `tea issue list` and `tea issue view 5`.
The same applies to `pulls`, `notifications` and the other groups.
Subcommands:
| Old | tea 1.0 |
|---|---|
| `issues reopen`, `pulls reopen` (alias `open`) | `issue reopen`, `pr reopen` |
| `pulls approve <n> [comment]` | `pr review <n> --event APPROVED [--body TEXT]` |
| `pulls reject <n> <comment>` | `pr review <n> --event REQUEST_CHANGES --body TEXT` |
| `pulls review <n>` | `pr review <n>` |
| `pulls review-comments` | `pr review comments` |
| `pulls reply`, `resolve`, `unresolve` | `pr review reply`, `pr review resolve`, `pr review unresolve` |
| `labels update --id ID` | `label edit ID` |
| `labels delete --id ID` | `label delete ID` |
| `labels list --save` | `label export` |
| `milestones issues <name>` | `milestone issue list <milestone-id>`, or `milestone issue list --by-name <name>` |
| `milestones issues add\|remove` | `milestone issue add\|remove <milestone-id> <number>...` (`--by-name` selects by title) |
| `releases assets create` | `release asset upload` |
| `times add` | `time create` |
| `times list [user\|#issue]` | `time list [--username USER\|--issue N]` |
| `repos search` | `search repo` |
| `repos create-from-template` | `repo create --template OWNER/REPO` |
| `actions secrets create` | `secret set` |
| `actions variables list --name NAME` | `variable view NAME` |
| `actions runs delete` (alias `cancel`) | `run delete`; `run cancel` cancels without deleting |
| `actions workflows dispatch` | `workflow run` |
| `webhooks update` | `webhook edit` |
| `comments add <n> [body]` | `issue comment create <n> --body TEXT` (also `pr comment create`) |
| `notifications read\|unread [all\|id]` | `notification mark-read\|mark-unread [id]...`; use `--all` for every filtered notification |
| `ssh-keys add` | `ssh-key create` |
| `login helper setup` | `auth setup-git` |
| `completion pwsh` | `completion powershell` |
Renamed flags that appear on many commands:
| Old | tea 1.0 |
|---|---|
| `--description` / `-d`, `--description-file` (issues, pulls, comments) | `--body`, `--body-file` |
| `--note` / `-n`, `--note-file` / `-f` (releases) | `--body`, `--body-file` |
| `--content` / `-c` (wiki) | `--body`, `--body-file` |
| `--labels` / `-L`, `--assignees` / `-a`, `--milestones` / `-m` | `--label`, `--assignee`, `--milestone` |
| `--referenced-version` / `-v` | `--ref` |
| `--keyword` / `-k` | `--search` |
| `--from` / `-F` (issue list) | `--since` |
| `--states` / `-s`, `--types` / `-t` (notifications) | `--status`, `--type` |
| `--page` / `-p`, `--limit` / `--lm` | `--page`, `--limit` |
| `--style` / `-s` (pr merge) | `--method` / `-s` |
| `--owner` / `-O`, `--init`, `--labels`, `--trustmodel`, `--branch`, `--template` (repo create) | `--org`, `--auto-init`, `--label-template`, `--trust-model`, `--default-branch`, `--as-template` |
| `--inactive` (webhook) | `--active=false` |
| `--out` (man) | `--output-file` / `-o` |
Most other short flags were dropped; the long names are unchanged unless listed
here. Two flags kept their name but changed meaning:
- `workflow run`: `-f` was `--follow` and now means `--field KEY=VALUE`;
`--follow` has no shorthand. `-r` (`--ref`) and `-i` (`--input`) are unchanged.
- `api`: `--field` (`-f`) sent a string and `--Field` (`-F`) a typed value. Now
`--raw-field` / `-f` sends a string and `--field` / `-F` a typed value, so the
shorthands behave as before. `--data` / `-d` became `--input FILE` (or `-` for
stdin), `--include` lost `-i`, and `--output` / `-o` became `--output-file`.
## Changed positional arguments
| Command | Old | tea 1.0 |
|---|---|---|
| `milestone close\|reopen\|delete\|edit\|view` | milestone name | milestone ID; add `--by-name` to select by exact title |
| `milestone issue list\|add\|remove` | milestone name | milestone ID; add `--by-name` to select by exact title |
| `release asset delete <tag>` | attachment name | asset ID; add `--by-name` to select by exact name |
| `label edit\|delete` | `--id ID` | `ID` |
| `repo delete` | `--name NAME --owner OWNER` | optional `OWNER/REPO` argument (or `--repo`) |
| `issue comment create` | optional body argument | `--body`, `--body-file` or `--editor` |
A milestone whose title is a number is now read as an ID unless you pass
`--by-name`. Destructive commands still ask for confirmation unless `--yes` is
given.
## Output formats
`--output` / `-o` (`table`, `simple`, `csv`, `tsv`, `yaml`, `json`) and `--fields`
are gone. Human output is plain text; scripts should use JSON:
```sh
# old: tea issues list --fields index,title -o csv
tea issue list --json number,title --jq '.[] | "\(.number),\(.title)"'
# old: tea notifications --mine -o simple | xargs notify-send
tea notification list --mine --json title --jq '.[].title' | xargs -n1 notify-send
```
`--json` alone prints every field; `--json a,b` selects fields and rejects unknown
names; `--jq` filters the result. Commands that produce no resource, such as
deletes, reject `--json` with a usage error instead of printing nothing.
Lists print aligned columns without a header row and with fewer columns than
before: the ID or number first, then the title or name, then the state and a few
details (`issue list` and `pr list` show number, title, state and author). Do not
parse them; the columns may change. On a color terminal the first column links to
the resource. Tabs and line breaks in list cells become spaces, and control
characters such as escape sequences are dropped from all human output, bodies
included. Commands that change several resources at once, such as
`issue close 1 2`, `issue edit`, `milestone close`, `release edit` or
`notification mark-read`, print one table of the changed items in the matching
list's columns. When a list continues past the requested page, tea prints a
`--page` hint on stderr.
Issue, pull request and other bodies are printed as raw Markdown instead of being
rendered. Long output on a terminal goes through a pager (`TEA_PAGER`, the
`pager` preference or `PAGER`). Each command starts the pager at most once.
## Removed features
| Feature | Replacement |
|---|---|
| `tea open [number\|issues\|pulls\|releases\|commits\|branches\|wiki\|labels\|milestones\|activity\|settings\|<ref>]` | `tea issue view N --web`, `tea pr view N --web`, `tea repo view --web`; for other pages open `$(tea repo view --json url --jq .url)/releases` and similar |
| Basic-auth token creation (`login add --user/--password/--otp/--scopes`) | create a token in the web UI, or `tea auth login --oauth` |
| `login edit` | `tea config set --host URL <key> <value>` |
| Output formats and `--fields` | `--json` and `--jq` |
| Markdown rendering of bodies | raw Markdown, optionally paged |
| `contrib/autocomplete.*` scripts and the `--generate-shell-completion` protocol | `tea completion <shell>` |
| `GH_TOKEN`, `GITEA_SERVER_*`, `GITEA_SCOPES` | `GITEA_TOKEN`, `tea auth login` |
| `--vvv` | `--debug` |
### Shell completion
Completion scripts saved from an older `tea completion` (or the removed
`contrib/autocomplete.*` files) call tea with `--generate-shell-completion`, which
tea 1.0 rejects, so completion silently stops working. Regenerate them:
```sh
source <(tea completion bash) # ~/.bashrc
source <(tea completion zsh) # ~/.zshrc
tea completion fish > ~/.config/fish/completions/tea.fish
tea completion powershell | Out-String | Invoke-Expression # PowerShell profile
```
Packagers can ship the pre-generated scripts and man pages from the release docs
archive, or run `make docs`.
## Behavior changes
- `pr checkout N` creates or reuses the local branch `pr/N`; it no longer
switches to another local branch that already points at the PR head. Use
`--branch NAME` to check out into a branch you choose (it must point at the PR
head; `--update` fast-forwards it) or `--detach` for a detached checkout.
`-b` now takes the branch name.
- `webhook edit` must be told what to do with the delivery authorization header
on every call, because Gitea replaces it: pass `--authorization-header`,
`--authorization-header-file` or `--clear-authorization`. The signing secret
cannot be edited; recreate the hook to rotate it.
- `notification mark-read`, `mark-unread`, `pin` and `unpin` act on the given IDs;
pass `--all` to apply them to every notification matching the filters.
- `--no-input` disables prompts, editors and browsers. With `--json`, tea never
prompts unless `--interactive` is given; required values must come from flags.
- Destructive commands confirm on a terminal and need `--yes` elsewhere.
- `--limit` accepts 1 to 100 and `--page` a positive number; other values are
usage errors instead of being passed to the server.
- In `--json` output, timestamps the server leaves unset print as `""`, or as
`null` for optional fields such as deadlines, instead of
`0001-01-01T00:00:00Z`.
- More input is checked before anything is sent: release titles, issue titles
and comment bodies cannot be empty, a review needs a body or inline comments
(unless it approves), team creation needs a permission, migrations from
GitHub, Gitea, GitLab and Gogs need an access token, and `workflow run` needs
a ref (`--ref` or a checked-out branch).
- `pr merge` merges the head it read and refuses when the branch moved in the
meantime; run it again to merge the new head.
- Preferences follow the git/gh order: an explicit `tea config set` value wins
over `VISUAL`/`EDITOR`, `PAGER` and `BROWSER`, which win over the defaults;
`TEA_EDITOR`, `TEA_PAGER` and `TEA_COLOR` override both.
+3 -3
View File
@@ -1,5 +1,5 @@
{
description = "Tea - A command line tool to interact with Gitea";
description = "gitea-cli - A command line tool to interact with Gitea";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
@@ -13,7 +13,7 @@
in
{
devShells.default = pkgs.mkShell {
name = "tea-dev-environment";
name = "gitea-cli-dev-environment";
buildInputs = with pkgs; [
go_1_27
gopls
@@ -22,7 +22,7 @@
];
shellHook = ''
echo 'Welcome to tea. Check out the Makefile for runnable targets.'
echo 'Welcome to gt. Check out the Makefile for runnable targets.'
'';
};
}
+1 -1
View File
@@ -1,4 +1,4 @@
module gitea.dev/tea
module gitea.dev/cli
go 1.27.0
+2 -2
View File
@@ -6,8 +6,8 @@ package app
import (
"strconv"
"gitea.dev/tea/internal/services"
"gitea.dev/tea/internal/terminal"
"gitea.dev/cli/internal/services"
"gitea.dev/cli/internal/terminal"
"github.com/spf13/cobra"
)
+2 -2
View File
@@ -10,8 +10,8 @@ import (
"io"
"time"
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/services"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/services"
"github.com/spf13/cobra"
)
+3 -3
View File
@@ -9,9 +9,9 @@ import (
"regexp"
"strings"
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/services"
"gitea.dev/tea/internal/terminal"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/services"
"gitea.dev/cli/internal/terminal"
"github.com/spf13/cobra"
)
+3 -3
View File
@@ -11,9 +11,9 @@ import (
"strings"
"time"
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/services"
"gitea.dev/tea/internal/terminal"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/services"
"gitea.dev/cli/internal/terminal"
"github.com/spf13/cobra"
)
+5 -5
View File
@@ -12,7 +12,7 @@ import (
"testing"
"time"
"gitea.dev/tea/internal/services"
"gitea.dev/cli/internal/services"
"github.com/stretchr/testify/require"
)
@@ -20,7 +20,7 @@ func TestGiteaActionsQueuedRunLifecycle(t *testing.T) {
_, deps, out, diagnostics := giteaDeps(t)
execute := outputExecutor(t, &deps, out, diagnostics)
var repo services.Repository
require.NoError(t, json.Unmarshal(execute("repo", "create", fmt.Sprintf("tea-actions-%d", time.Now().UnixNano()), "--auto-init", "--private", "--json"), &repo))
require.NoError(t, json.Unmarshal(execute("repo", "create", fmt.Sprintf("gt-actions-%d", time.Now().UnixNano()), "--auto-init", "--private", "--json"), &repo))
t.Cleanup(func() {
if err := Execute(context.Background(), deps, []string{"repo", "delete", "-R", repo.FullName, "--yes"}); err != nil {
t.Errorf("repository cleanup: %v", err)
@@ -28,11 +28,11 @@ func TestGiteaActionsQueuedRunLifecycle(t *testing.T) {
})
require.NoError(t, json.Unmarshal(execute("repo", "edit", "-R", repo.FullName, "--actions", "--json"), &repo))
require.True(t, repo.ActionsEnabled)
workflow := "name: Tea fixture\non:\n push:\n workflow_dispatch:\njobs:\n build:\n runs-on: tea-disposable-no-runner\n steps:\n - run: echo tea fixture\n"
workflow := "name: gitea-cli fixture\non:\n push:\n workflow_dispatch:\njobs:\n build:\n runs-on: gt-disposable-no-runner\n steps:\n - run: echo gt fixture\n"
payload, err := json.Marshal(map[string]string{"branch": repo.DefaultBranch, "content": base64.StdEncoding.EncodeToString([]byte(workflow)), "message": "Disposable workflow fixture"})
require.NoError(t, err)
deps.Streams.In = bytes.NewReader(payload)
execute("api", "repos/"+repo.FullName+"/contents/.gitea/workflows/tea.yml", "--input", "-")
execute("api", "repos/"+repo.FullName+"/contents/.gitea/workflows/gt.yml", "--input", "-")
var runs []services.Run
deadline := time.Now().Add(30 * time.Second)
for time.Now().Before(deadline) {
@@ -53,7 +53,7 @@ func TestGiteaActionsQueuedRunLifecycle(t *testing.T) {
require.NotEmpty(t, matching)
out.Reset()
diagnostics.Reset()
require.NoError(t, json.Unmarshal(execute("run", "list", "-R", repo.FullName, "--workflow", "tea.yml", "--json"), &matching))
require.NoError(t, json.Unmarshal(execute("run", "list", "-R", repo.FullName, "--workflow", "gt.yml", "--json"), &matching))
require.NotEmpty(t, matching)
require.NoError(t, json.Unmarshal(execute("run", "list", "-R", repo.FullName, "--branch", "does-not-exist", "--json"), &matching))
+1 -1
View File
@@ -9,7 +9,7 @@ import (
"testing"
"time"
"gitea.dev/tea/internal/clierr"
"gitea.dev/cli/internal/clierr"
"github.com/stretchr/testify/require"
)
+3 -3
View File
@@ -9,9 +9,9 @@ import (
"strconv"
"strings"
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/services"
"gitea.dev/tea/internal/terminal"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/services"
"gitea.dev/cli/internal/terminal"
"github.com/spf13/cobra"
)
+2 -2
View File
@@ -15,8 +15,8 @@ import (
"sort"
"strings"
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/services"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/services"
"github.com/spf13/cobra"
)
+2 -2
View File
@@ -12,13 +12,13 @@ import (
"testing"
"time"
"gitea.dev/tea/internal/services"
"gitea.dev/cli/internal/services"
"github.com/stretchr/testify/require"
)
func TestGiteaRawAPIFieldsAndPagination(t *testing.T) {
_, deps, out, diagnostics := giteaDeps(t)
require.NoError(t, Execute(context.Background(), deps, []string{"repo", "create", fmt.Sprintf("tea-api-%d", time.Now().UnixNano()), "--private", "--json"}))
require.NoError(t, Execute(context.Background(), deps, []string{"repo", "create", fmt.Sprintf("gt-api-%d", time.Now().UnixNano()), "--private", "--json"}))
var repo services.Repository
require.NoError(t, json.Unmarshal(out.Bytes(), &repo))
t.Cleanup(func() {
+9 -9
View File
@@ -13,8 +13,8 @@ import (
"strings"
"testing"
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/transport"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/transport"
"github.com/stretchr/testify/require"
)
@@ -35,7 +35,7 @@ func TestAPIFieldsPlaceholdersAndAtomicPagination(t *testing.T) {
}
require.Equal(t, "open", r.URL.Query().Get("state"))
require.Equal(t, "2", r.URL.Query().Get("limit"))
w.Header().Set("X-Tea-Test", "header-on-stderr")
w.Header().Set("X-Gt-Test", "header-on-stderr")
if r.URL.Query().Get("page") == "2" {
if failSecond {
w.WriteHeader(403)
@@ -61,7 +61,7 @@ func TestAPIFieldsPlaceholdersAndAtomicPagination(t *testing.T) {
args := []string{"api", "repos/{owner}/{repo}/issues", "-R", "alice/project", "-X", "GET", "-f", "state=open", "-F", "limit=2", "--paginate", "--include", "--output-file", output}
require.NoError(t, Execute(context.Background(), deps, args))
require.Empty(t, out.String())
require.Contains(t, diagnostics.String(), "X-Tea-Test: header-on-stderr")
require.Contains(t, diagnostics.String(), "X-Gt-Test: header-on-stderr")
data, err := os.ReadFile(output)
require.NoError(t, err)
require.Equal(t, "[{\"number\":1}]\n[{\"number\":2}]\n", string(data))
@@ -114,7 +114,7 @@ func TestAPIDebugLogsRequestsToStderr(t *testing.T) {
func TestAPIWritesErrorResponses(t *testing.T) {
server := newAuthenticatedServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.Header().Set("X-Tea-Test", "error-header")
w.Header().Set("X-Gt-Test", "error-header")
w.WriteHeader(http.StatusUnprocessableEntity)
_, _ = w.Write([]byte(`{"message":"invalid","errors":["title"]}`))
}))
@@ -126,7 +126,7 @@ func TestAPIWritesErrorResponses(t *testing.T) {
require.Equal(t, http.StatusUnprocessableEntity, apiErr.Status)
require.Equal(t, `{"message":"invalid","errors":["title"]}`, out.String())
require.Contains(t, diagnostics.String(), "422 Unprocessable Entity")
require.Contains(t, diagnostics.String(), "X-Tea-Test: error-header")
require.Contains(t, diagnostics.String(), "X-Gt-Test: error-header")
}
func TestAPITypedFieldsInferJSONValues(t *testing.T) {
@@ -142,14 +142,14 @@ func TestAPIHeadersPreserveRawResponseAndRejectCredentialOverrides(t *testing.T)
server := newAuthenticatedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
calls++
require.Equal(t, "application/octet-stream", r.Header.Get("Accept"))
require.Equal(t, []string{"one", "two"}, r.Header.Values("X-Tea-Test"))
require.Equal(t, []string{"one", "two"}, r.Header.Values("X-Gt-Test"))
require.Equal(t, "token secret", r.Header.Get("Authorization"))
_, _ = w.Write([]byte{0, 1, 2, 255})
}))
defer server.Close()
deps, out, _ := testDeps(t)
deps.Getenv = envFunc(map[string]string{"TEA_HOST": server.URL, "GITEA_TOKEN": "secret"})
require.NoError(t, Execute(context.Background(), deps, []string{"api", "user/data", "-H", "Accept: application/octet-stream", "-H", "X-Tea-Test: one", "-H", "X-Tea-Test: two"}))
deps.Getenv = envFunc(map[string]string{"GITEA_CLI_HOST": server.URL, "GITEA_TOKEN": "secret"})
require.NoError(t, Execute(context.Background(), deps, []string{"api", "user/data", "-H", "Accept: application/octet-stream", "-H", "X-Gt-Test: one", "-H", "X-Gt-Test: two"}))
require.Equal(t, []byte{0, 1, 2, 255}, out.Bytes())
for _, header := range []string{"Authorization: sensitive-value", "Host: unrelated.example.org", "Proxy-Authorization: sensitive-value", "Content-Length: 100", "Connection: upgrade", "Bad Name: value", "X-Test: value\r\nAuthorization: sensitive-value", "X-Test: value\x00", "missing-colon"} {
out.Reset()
+21 -21
View File
@@ -1,7 +1,7 @@
// Copyright 2026 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
// Package app builds the tea command tree and its injected dependencies.
// Package app builds the gt command tree and its injected dependencies.
package app
import (
@@ -16,15 +16,15 @@ import (
"time"
"unicode"
"gitea.dev/tea/internal/aliases"
"gitea.dev/tea/internal/auth"
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/git"
"gitea.dev/tea/internal/services"
"gitea.dev/tea/internal/settings"
"gitea.dev/tea/internal/terminal"
"gitea.dev/tea/internal/transport"
"gitea.dev/tea/internal/version"
"gitea.dev/cli/internal/aliases"
"gitea.dev/cli/internal/auth"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/git"
"gitea.dev/cli/internal/services"
"gitea.dev/cli/internal/settings"
"gitea.dev/cli/internal/terminal"
"gitea.dev/cli/internal/transport"
"gitea.dev/cli/internal/version"
"github.com/spf13/cobra"
)
@@ -53,7 +53,7 @@ type Dependencies struct {
// System connects the CLI to the current environment and terminal.
func System() Dependencies {
streams := terminal.System()
store := settings.New(os.Getenv("TEA_CONFIG_DIR"))
store := settings.New(os.Getenv("GITEA_CLI_CONFIG_DIR"))
prompter := &terminal.FormPrompter{Streams: streams}
return Dependencies{Browser: terminal.SystemBrowser{ErrOut: streams.ErrOut}, Editor: terminal.SystemEditor{Streams: streams}, Pager: terminal.SystemPager{}, Executable: os.Executable, Git: git.System{In: streams.In, ErrOut: streams.ErrOut}, Now: time.Now, Settings: store, Credentials: &auth.Store{Dir: store.Dir, Keyring: auth.SystemKeyring{}}, Streams: streams, Prompter: prompter, IssueForm: prompter, IssueEditForm: prompter, PullForm: prompter, ReviewForm: prompter, MergeForm: prompter, MilestoneForm: prompter, Getenv: os.Getenv, Client: transport.New}
}
@@ -97,7 +97,7 @@ func NewRoot(deps Dependencies) *cobra.Command {
return client(instance, token, insecure)
}
}
root := &cobra.Command{Use: "tea", Short: "Work with Gitea from your terminal", Version: version.Format(), SilenceErrors: true, SilenceUsage: true}
root := &cobra.Command{Use: "gt", Short: "Work with Gitea from your terminal", Version: version.Format(), SilenceErrors: true, SilenceUsage: true}
root.SetIn(deps.Streams.In)
root.SetOut(deps.Streams.Out)
root.SetErr(deps.Streams.ErrOut)
@@ -117,7 +117,7 @@ func NewRoot(deps Dependencies) *cobra.Command {
flags.BoolVar(&a.options.yes, "yes", false, "Accept confirmations without prompting")
flags.BoolVar(&a.options.debug, "debug", false, "Log the method, URL, status, and duration of each HTTP request to stderr")
root.PersistentPreRunE = func(cmd *cobra.Command, _ []string) error {
if reason := cmd.Annotations["tea.text"]; reason != "" && a.options.json != "" {
if reason := cmd.Annotations["gt.text"]; reason != "" && a.options.json != "" {
return clierr.Wrap(clierr.Usage, fmt.Errorf("%s; --json is not supported", reason))
}
if flag := cmd.Flags().Lookup("web"); flag != nil && flag.Value.String() == "true" && (a.options.json != "" || a.options.jq != "") {
@@ -150,7 +150,7 @@ func NewRoot(deps Dependencies) *cobra.Command {
}
root.AddCommand(a.configCommand(), a.aliasCommand(), a.authCommand(), a.apiCommand(), a.repoCommand(), a.issueCommand(), a.prCommand(), a.doctorCommand(), a.workflowCommand(), a.runCommand(), a.labelCommand(), a.milestoneCommand(), a.sshKeyCommand(), a.timeCommand(), a.wikiCommand(), a.actionValueCommand(true), a.actionValueCommand(false), a.releaseCommand(), a.organizationCommand(), a.notificationCommand(), a.teamCommand(), a.branchCommand(), a.webhookCommand(), a.adminCommand(), a.searchCommand(), a.statusCommand(false))
root.AddCommand(a.manCommand())
root.AddCommand(&cobra.Command{Use: "version", Short: "Print tea's version", Annotations: textOutput("version prints text"), RunE: func(cmd *cobra.Command, _ []string) error {
root.AddCommand(&cobra.Command{Use: "version", Short: "Print gt's version", Annotations: textOutput("version prints text"), RunE: func(cmd *cobra.Command, _ []string) error {
_, err := fmt.Fprintln(cmd.OutOrStdout(), version.Format())
return err
}})
@@ -163,7 +163,7 @@ func NewRoot(deps Dependencies) *cobra.Command {
// offline reports commands that must work without valid settings.
func offline(cmd *cobra.Command) bool {
if cmd.Annotations["tea.group"] == "true" {
if cmd.Annotations["gt.group"] == "true" {
return true
}
switch cmd.Name() {
@@ -173,13 +173,13 @@ func offline(cmd *cobra.Command) bool {
return cmd.HasParent() && cmd.Parent().Name() == "completion"
}
// rejectUnknownSubcommands makes `tea bogus` and `tea issue bogus` usage errors instead of printing help.
// rejectUnknownSubcommands makes `gt bogus` and `gt issue bogus` usage errors instead of printing help.
func rejectUnknownSubcommands(cmd *cobra.Command) {
if cmd.HasSubCommands() && !cmd.Runnable() {
if cmd.Annotations == nil {
cmd.Annotations = map[string]string{}
}
cmd.Annotations["tea.group"] = "true"
cmd.Annotations["gt.group"] = "true"
cmd.Args, cmd.SuggestionsMinimumDistance = cobra.ArbitraryArgs, 2
cmd.RunE = func(cmd *cobra.Command, args []string) error {
if len(args) == 0 {
@@ -200,7 +200,7 @@ func rejectUnknownSubcommands(cmd *cobra.Command) {
func builtins(root *cobra.Command) map[string]bool {
names := map[string]bool{"help": true, "completion": true}
for _, cmd := range root.Commands() {
if cmd.Annotations["tea.alias"] != "true" {
if cmd.Annotations["gt.alias"] != "true" {
names[cmd.Name()] = true
}
}
@@ -243,7 +243,7 @@ func Execute(ctx context.Context, deps Dependencies, args []string) error {
if loadErr == nil {
for name, expansion := range snapshot.Preferences.Aliases {
if aliases.Check(name, snapshot.Preferences.Aliases, names) == nil {
root.AddCommand(&cobra.Command{Use: name, Short: "Alias for " + expansion, Annotations: map[string]string{"tea.alias": "true"}, RunE: func(*cobra.Command, []string) error {
root.AddCommand(&cobra.Command{Use: name, Short: "Alias for " + expansion, Annotations: map[string]string{"gt.alias": "true"}, RunE: func(*cobra.Command, []string) error {
return clierr.Wrap(clierr.Usage, errors.New("alias must be expanded before execution"))
}})
}
@@ -311,7 +311,7 @@ func titleCase(s string) string {
// textOutput marks a command whose output is not a JSON resource, so --json is rejected up front.
func textOutput(reason string) map[string]string {
return map[string]string{"tea.text": reason}
return map[string]string{"gt.text": reason}
}
// commandIndex skips persistent flags without parsing or mutating command state.
@@ -373,7 +373,7 @@ func commandOutputFields(cmd *cobra.Command) []string {
"ssh_key", "ssh_agent", "ssh_certificate_principal", "ssh_key_fingerprint",
}
}
case "tea":
case "gt":
if cmd.Name() == "doctor" {
return jsonFields[target]()
}
+4 -4
View File
@@ -11,7 +11,7 @@ import (
"path/filepath"
"testing"
"gitea.dev/tea/internal/clierr"
"gitea.dev/cli/internal/clierr"
"github.com/stretchr/testify/require"
)
@@ -63,7 +63,7 @@ func TestCommandLineEdgeCases(t *testing.T) {
err = Execute(context.Background(), deps, []string{"config", "list", "--jq", ".", "--remote", "-h"})
require.ErrorContains(t, err, "--jq requires --json")
require.NoError(t, Execute(context.Background(), deps, []string{"--version"}))
require.NotContains(t, out.String(), "tea version")
require.NotContains(t, out.String(), "gt version")
}
func TestAliasesAfterGlobalFlagsAndNestedHelp(t *testing.T) {
@@ -89,10 +89,10 @@ func TestJoinJSONFields(t *testing.T) {
{[]string{"issue", "list", "--json", "--state", "open"}, []string{"issue", "list", "--json", "--state", "open"}},
{[]string{"search", "issues", "--", "--json", "id"}, []string{"search", "issues", "--", "--json", "id"}},
{[]string{"issue", "list", "--json", "Number"}, []string{"issue", "list", "--json", "Number"}},
{[]string{"search", "repo", "--json", "tea"}, []string{"search", "repo", "--json", "tea"}},
{[]string{"search", "repo", "--json", "gt"}, []string{"search", "repo", "--json", "gt"}},
{[]string{"search", "issue", "--json", "bug"}, []string{"search", "issue", "--json", "bug"}},
{[]string{"repo", "clone", "--json", "project"}, []string{"repo", "clone", "--json", "project"}},
{[]string{"search", "repo", "--json", "name,url", "tea"}, []string{"search", "repo", "--json=name,url", "tea"}},
{[]string{"search", "repo", "--json", "name,url", "gt"}, []string{"search", "repo", "--json=name,url", "gt"}},
{[]string{"--json", "number", "my-alias"}, []string{"--json=number", "my-alias"}},
} {
deps, _, _ := testDeps(t)
+1 -1
View File
@@ -13,7 +13,7 @@ import (
"strings"
"time"
"gitea.dev/tea/internal/clierr"
"gitea.dev/cli/internal/clierr"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
+2 -2
View File
@@ -6,8 +6,8 @@ package app
import (
"strconv"
"gitea.dev/tea/internal/services"
"gitea.dev/tea/internal/terminal"
"gitea.dev/cli/internal/services"
"gitea.dev/cli/internal/terminal"
"github.com/spf13/cobra"
)
+15 -15
View File
@@ -13,11 +13,11 @@ import (
"strings"
"time"
"gitea.dev/tea/internal/auth"
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/services"
"gitea.dev/tea/internal/settings"
"gitea.dev/tea/internal/terminal"
"gitea.dev/cli/internal/auth"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/services"
"gitea.dev/cli/internal/settings"
"gitea.dev/cli/internal/terminal"
"github.com/spf13/cobra"
)
@@ -96,7 +96,7 @@ func (a *application) authCommand() *cobra.Command {
}
instance := a.options.host
if instance == "" {
instance = a.deps.Getenv("TEA_HOST")
instance = a.deps.Getenv("GITEA_CLI_HOST")
}
if instance == "" {
instance = a.deps.Getenv("GITEA_INSTANCE_URL")
@@ -148,7 +148,7 @@ func (a *application) authCommand() *cobra.Command {
return err
}
if selectedUser, _ := a.selectedUser(); !services.MatchAccount(selectedUser, user) {
return clierr.Wrap(clierr.Usage, errors.New("authenticated account does not match --user or TEA_USER"))
return clierr.Wrap(clierr.Usage, errors.New("authenticated account does not match --user or GITEA_CLI_USER"))
}
if prompted {
if err := a.confirm(cmd, "Save credentials for "+user+" on "+instance); err != nil {
@@ -173,7 +173,7 @@ func (a *application) authCommand() *cobra.Command {
clientID = auth.DefaultClientID
}
credential, err = auth.OAuthLogin(cmd.Context(), auth.OAuthOptions{Instance: instance, ClientID: clientID, HTTP: a.deps.Client(instance, "", insecure).HTTP, Authorize: func(_ context.Context, authorizationURL string) error {
if _, err := fmt.Fprintln(cmd.ErrOrStderr(), "Open this URL to authorize tea:", authorizationURL); err != nil {
if _, err := fmt.Fprintln(cmd.ErrOrStderr(), "Open this URL to authorize gt:", authorizationURL); err != nil {
return err
}
if err := a.openBrowser(cmd, authorizationURL); err != nil {
@@ -202,7 +202,7 @@ func (a *application) authCommand() *cobra.Command {
return err
}
if selectedUser, _ := a.selectedUser(); !services.MatchAccount(selectedUser, user) {
return clierr.Wrap(clierr.Usage, errors.New("token account does not match --user or TEA_USER"))
return clierr.Wrap(clierr.Usage, errors.New("token account does not match --user or GITEA_CLI_USER"))
}
if prompted {
if err := a.confirm(cmd, "Save credentials for "+user+" on "+instance); err != nil {
@@ -212,7 +212,7 @@ func (a *application) authCommand() *cobra.Command {
return manager.Register(instance, user, backend, method, auth.HostOptions{OAuthClientID: clientID, Insecure: insecure}, credential)
}}
login.Flags().BoolVar(&oauth, "oauth", false, "Authorize through a browser using OAuth PKCE")
login.Flags().StringVar(&clientID, "client-id", "", "OAuth client ID registered on the instance (default: the instance's stored ID, then tea's)")
login.Flags().StringVar(&clientID, "client-id", "", "OAuth client ID registered on the instance (default: the instance's stored ID, then gt's)")
login.Flags().BoolVar(&insecure, "insecure", false, "Skip TLS certificate verification for this instance")
login.Flags().BoolVar(&withToken, "with-token", false, "Read a personal access token from stdin")
login.Flags().StringVar(&sshKey, "ssh-key", "", "Authenticate with an SSH private key via HTTP signatures")
@@ -306,11 +306,11 @@ func (a *application) authCommand() *cobra.Command {
return a.deps.Settings.Update(settings.TargetHosts, func(s *settings.Snapshot) error {
host, exists := s.Hosts.Hosts[instance]
if !exists {
return clierr.Wrap(clierr.Usage, errors.New("instance is not configured; run tea auth login first"))
return clierr.Wrap(clierr.Usage, errors.New("instance is not configured; run gt auth login first"))
}
user, exists := matchAccount(host.Users, args[0])
if !exists {
return clierr.Wrap(clierr.Usage, errors.New("account is not configured on the selected instance; use tea auth status --host URL to list accounts"))
return clierr.Wrap(clierr.Usage, errors.New("account is not configured on the selected instance; use gt auth status --host URL to list accounts"))
}
host.User = user
s.Hosts.Hosts[instance] = host
@@ -328,7 +328,7 @@ func (a *application) authCommand() *cobra.Command {
return err
}
if _, exists := s.Hosts.Hosts[instance].Users[user]; !exists {
return clierr.Wrap(clierr.Usage, errors.New("account is not configured on the selected instance; use tea auth status --host URL to list accounts"))
return clierr.Wrap(clierr.Usage, errors.New("account is not configured on the selected instance; use gt auth status --host URL to list accounts"))
}
if err := a.confirm(cmd, "Remove account "+user+" on "+instance); err != nil {
return err
@@ -346,10 +346,10 @@ func (a *application) authCommand() *cobra.Command {
}
account, exists := t.host.Users[t.User]
if !exists {
return clierr.Wrap(clierr.Authentication, errors.New("no selected account on this instance; run tea auth login or tea auth switch"))
return clierr.Wrap(clierr.Authentication, errors.New("no selected account on this instance; run gt auth login or gt auth switch"))
}
if account.AuthMethod != settings.AuthOAuth {
return clierr.Wrap(clierr.Usage, errors.New("only OAuth accounts can be refreshed; use tea auth login to replace a token"))
return clierr.Wrap(clierr.Usage, errors.New("only OAuth accounts can be refreshed; use gt auth login to replace a token"))
}
manager, err := auth.NewManager(a.deps.Settings, a.deps.Credentials)
if err != nil {
+8 -8
View File
@@ -21,10 +21,10 @@ import (
"testing"
"time"
"gitea.dev/tea/internal/auth"
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/settings"
"gitea.dev/tea/internal/transport"
"gitea.dev/cli/internal/auth"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/settings"
"gitea.dev/cli/internal/transport"
"github.com/stretchr/testify/require"
"golang.org/x/crypto/ssh"
)
@@ -64,7 +64,7 @@ func TestLoginValidatesUserEnvironmentWithFlagPrecedence(t *testing.T) {
t.Run(test.name, func(t *testing.T) {
deps, _, _ := testDeps(t)
deps.Streams.In = strings.NewReader("private-login-token\n")
deps.Getenv = envFunc(map[string]string{"TEA_USER": test.environment})
deps.Getenv = envFunc(map[string]string{"GITEA_CLI_USER": test.environment})
args := []string{"auth", "login", "--host", server.URL, "--with-token", "--credential-store", "file", "--no-input"}
if test.flag != "" {
args = append(args, "--user", test.flag)
@@ -179,8 +179,8 @@ func TestLogoutSelectsAccountWithoutAuthentication(t *testing.T) {
selected string
}{
{name: "active account", selected: "alice"},
{name: "environment account", environment: map[string]string{"TEA_HOST": "https://example.org", "TEA_USER": "bob", "GITEA_TOKEN": "expired"}, selected: "bob"},
{name: "flag overrides environment", flags: []string{"--host", "https://example.org", "--user", "alice"}, environment: map[string]string{"TEA_HOST": "https://other.example.org", "TEA_USER": "bob"}, selected: "alice"},
{name: "environment account", environment: map[string]string{"GITEA_CLI_HOST": "https://example.org", "GITEA_CLI_USER": "bob", "GITEA_TOKEN": "expired"}, selected: "bob"},
{name: "flag overrides environment", flags: []string{"--host", "https://example.org", "--user", "alice"}, environment: map[string]string{"GITEA_CLI_HOST": "https://other.example.org", "GITEA_CLI_USER": "bob"}, selected: "alice"},
} {
t.Run(test.name, func(t *testing.T) {
deps, out, _ := testDeps(t)
@@ -512,7 +512,7 @@ func TestOAuthLoginOpensAuthorizationURLInBrowser(t *testing.T) {
require.Equal(t, http.StatusOK, callback.StatusCode)
_ = callback.Body.Close()
require.NoError(t, <-done)
require.Contains(t, diagnostics.String(), "Open this URL to authorize tea:")
require.Contains(t, diagnostics.String(), "Open this URL to authorize gt:")
require.Contains(t, diagnostics.String(), resource)
snapshot, err := deps.Settings.Load()
require.NoError(t, err)
+3 -3
View File
@@ -9,9 +9,9 @@ import (
"strconv"
"strings"
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/services"
"gitea.dev/tea/internal/terminal"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/services"
"gitea.dev/cli/internal/terminal"
"github.com/spf13/cobra"
)
+1 -1
View File
@@ -9,7 +9,7 @@ import (
"net/http"
"testing"
"gitea.dev/tea/internal/clierr"
"gitea.dev/cli/internal/clierr"
"github.com/stretchr/testify/require"
)
+4 -4
View File
@@ -10,10 +10,10 @@ import (
"slices"
"strings"
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/git"
"gitea.dev/tea/internal/services"
"gitea.dev/tea/internal/settings"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/git"
"gitea.dev/cli/internal/services"
"gitea.dev/cli/internal/settings"
"github.com/spf13/cobra"
)
+2 -2
View File
@@ -10,8 +10,8 @@ import (
"strings"
"testing"
"gitea.dev/tea/internal/git"
"gitea.dev/tea/internal/settings"
"gitea.dev/cli/internal/git"
"gitea.dev/cli/internal/settings"
"github.com/stretchr/testify/require"
)
+3 -3
View File
@@ -9,9 +9,9 @@ import (
"fmt"
"time"
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/services"
"gitea.dev/tea/internal/terminal"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/services"
"gitea.dev/cli/internal/terminal"
"github.com/spf13/cobra"
)
+1 -1
View File
@@ -8,7 +8,7 @@ import (
"net/http"
"testing"
"gitea.dev/tea/internal/clierr"
"gitea.dev/cli/internal/clierr"
"github.com/stretchr/testify/require"
)
+2 -2
View File
@@ -12,8 +12,8 @@ import (
"strings"
"testing"
"gitea.dev/tea/internal/git"
"gitea.dev/tea/internal/settings"
"gitea.dev/cli/internal/git"
"gitea.dev/cli/internal/settings"
"github.com/stretchr/testify/require"
)
+3 -3
View File
@@ -9,9 +9,9 @@ import (
"strconv"
"strings"
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/services"
"gitea.dev/tea/internal/terminal"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/services"
"gitea.dev/cli/internal/terminal"
"github.com/spf13/cobra"
)
+27 -27
View File
@@ -10,10 +10,10 @@ import (
"sort"
"strings"
"gitea.dev/tea/internal/aliases"
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/settings"
"gitea.dev/tea/internal/terminal"
"gitea.dev/cli/internal/aliases"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/settings"
"gitea.dev/cli/internal/terminal"
"github.com/spf13/cobra"
)
@@ -29,7 +29,7 @@ func (a *application) effectivePreferences(snapshot settings.Snapshot) (settings
if a.options.host != "" {
host, source = a.options.host, "--host"
} else {
for _, key := range []string{"TEA_HOST", "GITEA_INSTANCE_URL"} {
for _, key := range []string{"GITEA_CLI_HOST", "GITEA_INSTANCE_URL"} {
if value := a.deps.Getenv(key); value != "" {
host, source = value, key
break
@@ -57,20 +57,20 @@ func (a *application) effectivePreferences(snapshot settings.Snapshot) (settings
preferences.Remote = a.options.remote
sources["remote"] = "--remote"
}
if value := strings.TrimSpace(a.deps.Getenv("TEA_PAGER")); value != "" {
if value := strings.TrimSpace(a.deps.Getenv("GITEA_CLI_PAGER")); value != "" {
preferences.Pager = value
sources["pager"] = "TEA_PAGER"
sources["pager"] = "GITEA_CLI_PAGER"
} else if value := strings.TrimSpace(a.deps.Getenv("PAGER")); value != "" && sources["pager"] == "" {
preferences.Pager = value
sources["pager"] = "PAGER"
}
if value := strings.TrimSpace(a.deps.Getenv("TEA_COLOR")); value != "" {
if value := strings.TrimSpace(a.deps.Getenv("GITEA_CLI_COLOR")); value != "" {
preferences.Color = value
sources["color"] = "TEA_COLOR"
sources["color"] = "GITEA_CLI_COLOR"
}
if value := a.deps.Getenv("TEA_EDITOR"); value != "" {
if value := a.deps.Getenv("GITEA_CLI_EDITOR"); value != "" {
preferences.Editor = value
sources["editor"] = "TEA_EDITOR"
sources["editor"] = "GITEA_CLI_EDITOR"
} else if value := a.deps.Getenv("VISUAL"); value != "" && sources["editor"] == "" {
preferences.Editor = value
sources["editor"] = "VISUAL"
@@ -89,9 +89,9 @@ func (a *application) configCommand() *cobra.Command {
group := &cobra.Command{Use: "config", Short: "Manage preferences", Long: `Manage preferences.
Settings live in config.yml and hosts.yml in the configuration directory
($TEA_CONFIG_DIR, or tea under the XDG config directory); tea config path prints both.
($GITEA_CLI_CONFIG_DIR, or gt under the XDG config directory); gt config path prints both.
config.yml preferences (tea config set <key> <value>):
config.yml preferences (gt config set <key> <value>):
default_host instance URL used when no --host, environment or repository selects one
git_protocol https or ssh for clone and checkout remotes
editor command used to edit bodies
@@ -100,29 +100,29 @@ config.yml preferences (tea config set <key> <value>):
browser command used to open web pages; never disables opening
color auto, always or never
remote Git remote used for repository discovery
aliases command aliases; manage them with tea alias
aliases command aliases; manage them with gt alias
hosts.yml per-instance settings (tea config set --host <url> <key> <value>):
user active account, changed only by tea auth switch
hosts.yml per-instance settings (gt config set --host <url> <key> <value>):
user active account, changed only by gt auth switch
ssh_host SSH host[:port] when it differs from the web host
insecure true skips TLS certificate verification
git_protocol https or ssh, overriding config.yml for this instance
oauth_client_id OAuth application used by tea auth login
oauth_client_id OAuth application used by gt auth login
Per-account SSH settings (tea config set --host <url> --user <name> <key> <value>):
Per-account SSH settings (gt config set --host <url> --user <name> <key> <value>):
ssh_key, ssh_agent, ssh_certificate_principal, ssh_key_fingerprint
Environment overrides:
TEA_CONFIG_DIR configuration directory
TEA_HOST, GITEA_INSTANCE_URL instance, overriding default_host
GITEA_CLI_CONFIG_DIR configuration directory
GITEA_CLI_HOST, GITEA_INSTANCE_URL instance, overriding default_host
GITEA_TOKEN access token for that instance instead of stored credentials
GITEA_INSTANCE_INSECURE with GITEA_TOKEN, skip TLS verification when true
GITEA_INSTANCE_SSH_HOST with GITEA_TOKEN, SSH host that identifies the instance's remotes
TEA_USER account on the selected instance
TEA_REPO repository as owner/name or URL
TEA_EDITOR editor, overriding config.yml
TEA_PAGER pager, overriding config.yml
TEA_COLOR color preference; NO_COLOR disables automatic color
GITEA_CLI_USER account on the selected instance
GITEA_CLI_REPO repository as owner/name or URL
GITEA_CLI_EDITOR editor, overriding config.yml
GITEA_CLI_PAGER pager, overriding config.yml
GITEA_CLI_COLOR color preference; NO_COLOR disables automatic color
VISUAL, EDITOR, PAGER, BROWSER editor (VISUAL first), pager and browser when config.yml sets none`}
group.AddCommand(&cobra.Command{Use: "path", Short: "Show configuration file paths", Annotations: textOutput("config path prints text"), Args: argsExact(0), RunE: func(cmd *cobra.Command, _ []string) error {
_, err := fmt.Fprintf(cmd.OutOrStdout(), "config\t%s\nhosts\t%s\n", filepath.Join(a.deps.Settings.Dir, "config.yml"), filepath.Join(a.deps.Settings.Dir, "hosts.yml"))
@@ -151,7 +151,7 @@ Environment overrides:
return err
}
if _, exists := snapshot.Hosts.Hosts[preferences.DefaultHost]; a.options.user != "" && !exists {
return clierr.Wrap(clierr.Usage, errors.New("instance is not configured; run tea auth login first"))
return clierr.Wrap(clierr.Usage, errors.New("instance is not configured; run gt auth login first"))
}
values := map[string]any{
"version": preferences.Version, "default_host": preferences.DefaultHost,
@@ -235,7 +235,7 @@ Environment overrides:
return a.deps.Settings.Update(settings.TargetHosts, func(s *settings.Snapshot) error {
host, exists := s.Hosts.Hosts[instance]
if !exists {
return clierr.Wrap(clierr.Usage, errors.New("instance is not configured; run tea auth login first"))
return clierr.Wrap(clierr.Usage, errors.New("instance is not configured; run gt auth login first"))
}
if a.options.user != "" {
user, exists := matchAccount(host.Users, a.options.user)
+7 -7
View File
@@ -9,8 +9,8 @@ import (
"path/filepath"
"testing"
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/settings"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/settings"
"github.com/stretchr/testify/require"
)
@@ -18,9 +18,9 @@ func TestConfigReportsEffectivePreferenceSourcesWithoutAuthentication(t *testing
deps, out, _ := testDeps(t)
require.NoError(t, deps.Settings.Update(settings.TargetPreferences, func(s *settings.Snapshot) error { s.Preferences.DefaultHost = "https://stored.example.org"; return nil }))
configureHost(t, deps, "https://env.example.org/base", settings.Host{GitProtocol: "ssh"})
deps.Getenv = envFunc(map[string]string{"TEA_HOST": "https://ENV.example.org/base/"})
deps.Getenv = envFunc(map[string]string{"GITEA_CLI_HOST": "https://ENV.example.org/base/"})
require.NoError(t, Execute(context.Background(), deps, []string{"config", "get", "default_host", "--show-source", "--json"}))
require.JSONEq(t, `{"default_host":{"value":"https://env.example.org/base","source":"TEA_HOST"}}`, out.String())
require.JSONEq(t, `{"default_host":{"value":"https://env.example.org/base","source":"GITEA_CLI_HOST"}}`, out.String())
out.Reset()
require.NoError(t, Execute(context.Background(), deps, []string{"config", "get", "git_protocol", "--show-source", "--json"}))
require.JSONEq(t, `{"git_protocol":{"value":"ssh","source":"hosts.yml https://env.example.org/base"}}`, out.String())
@@ -40,7 +40,7 @@ func TestInstanceConfigUpdatesPreserveAccountsAndGlobalPreferences(t *testing.T)
require.NoError(t, Execute(context.Background(), deps, []string{"config", "set", "editor", "vim"}))
global, err := os.ReadFile(filepath.Join(deps.Settings.Dir, "config.yml"))
require.NoError(t, err)
for _, value := range [][2]string{{"git_protocol", "ssh"}, {"ssh_host", "git.example.org:2222"}, {"insecure", "true"}, {"oauth_client_id", "tea-client"}} {
for _, value := range [][2]string{{"git_protocol", "ssh"}, {"ssh_host", "git.example.org:2222"}, {"insecure", "true"}, {"oauth_client_id", "gt-client"}} {
require.NoError(t, Execute(context.Background(), deps, []string{"config", "set", value[0], value[1], "--host", instance + "/"}))
}
current, err := os.ReadFile(filepath.Join(deps.Settings.Dir, "config.yml"))
@@ -96,8 +96,8 @@ func TestConfigHelpDocumentsSettingsAndEnvironment(t *testing.T) {
for _, name := range []string{
"default_host", "git_protocol", "editor", "prompt", "pager", "browser", "color", "remote", "aliases",
"user", "ssh_host", "insecure", "oauth_client_id", "ssh_key", "ssh_agent", "ssh_certificate_principal", "ssh_key_fingerprint",
"TEA_CONFIG_DIR", "TEA_HOST", "GITEA_INSTANCE_URL", "GITEA_TOKEN", "TEA_USER", "TEA_REPO", "TEA_EDITOR", "VISUAL", "EDITOR",
"TEA_PAGER", "PAGER", "TEA_COLOR", "NO_COLOR", "BROWSER",
"GITEA_CLI_CONFIG_DIR", "GITEA_CLI_HOST", "GITEA_INSTANCE_URL", "GITEA_TOKEN", "GITEA_CLI_USER", "GITEA_CLI_REPO", "GITEA_CLI_EDITOR", "VISUAL", "EDITOR",
"GITEA_CLI_PAGER", "PAGER", "GITEA_CLI_COLOR", "NO_COLOR", "BROWSER",
} {
require.Contains(t, out.String(), name)
}
+1 -1
View File
@@ -8,7 +8,7 @@ import (
"strconv"
"time"
"gitea.dev/tea/internal/clierr"
"gitea.dev/cli/internal/clierr"
"github.com/araddon/dateparse"
)
+1 -1
View File
@@ -10,7 +10,7 @@ import (
"strings"
unidiff "gitea.com/noerw/unidiff-comments"
"gitea.dev/tea/internal/terminal"
"gitea.dev/cli/internal/terminal"
)
const diffReviewHelp = `# This is the current diff of PR #%d on %s.
+4 -4
View File
@@ -8,9 +8,9 @@ import (
"fmt"
"strings"
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/services"
"gitea.dev/tea/internal/terminal"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/services"
"gitea.dev/cli/internal/terminal"
"github.com/spf13/cobra"
)
@@ -48,7 +48,7 @@ func (a *application) discussionSearchCommand(pulls bool) *cobra.Command {
return clierr.Wrap(clierr.Usage, errors.New("--team requires --owner"))
}
if opts.Team != "" && target.Repo != "" {
return clierr.Wrap(clierr.Usage, errors.New("--team requires instance-wide search; omit --repo or TEA_REPO"))
return clierr.Wrap(clierr.Usage, errors.New("--team requires instance-wide search; omit --repo or GITEA_CLI_REPO"))
}
if len(labelNames) > 0 {
if target.Repo != "" {
+1 -1
View File
@@ -9,7 +9,7 @@ import (
"testing"
"time"
"gitea.dev/tea/internal/clierr"
"gitea.dev/cli/internal/clierr"
"github.com/stretchr/testify/require"
)
+2 -2
View File
@@ -9,8 +9,8 @@ import (
"strings"
"time"
"gitea.dev/tea/internal/services"
"gitea.dev/tea/internal/terminal"
"gitea.dev/cli/internal/services"
"gitea.dev/cli/internal/terminal"
"github.com/spf13/cobra"
)
+2 -2
View File
@@ -6,7 +6,7 @@ package app
import (
"fmt"
"gitea.dev/tea/internal/clierr"
"gitea.dev/cli/internal/clierr"
"github.com/spf13/cobra"
)
@@ -15,7 +15,7 @@ func (a *application) doctorCommand() *cobra.Command {
// Repository discovery is best-effort: doctor must also work outside a clone.
// Only discovery (usage) failures fall back; authentication errors are reported.
target, err := a.resolve(cmd.Context(), true)
if clierr.ExitCode(err) == clierr.Usage && a.options.repo == "" && a.deps.Getenv("TEA_REPO") == "" {
if clierr.ExitCode(err) == clierr.Usage && a.options.repo == "" && a.deps.Getenv("GITEA_CLI_REPO") == "" {
target, err = a.resolve(cmd.Context(), false)
}
if err != nil {
+4 -4
View File
@@ -8,7 +8,7 @@ import (
"net/http"
"testing"
"gitea.dev/tea/internal/clierr"
"gitea.dev/cli/internal/clierr"
"github.com/stretchr/testify/require"
)
@@ -16,10 +16,10 @@ func TestEnvironmentCredentialReportsActualAccount(t *testing.T) {
server := newAuthenticatedServer(http.HandlerFunc(func(http.ResponseWriter, *http.Request) { t.Error("unexpected request") }))
defer server.Close()
deps, out, _ := testDeps(t)
deps.Getenv = serverEnv(server.URL, map[string]string{"TEA_USER": "ALICE"})
deps.Getenv = serverEnv(server.URL, map[string]string{"GITEA_CLI_USER": "ALICE"})
require.NoError(t, Execute(context.Background(), deps, []string{"doctor", "--json"}))
require.Contains(t, out.String(), `"user":"alice"`)
require.Contains(t, out.String(), `"user_source":"TEA_USER"`)
require.Contains(t, out.String(), `"user_source":"GITEA_CLI_USER"`)
}
func TestDoctorDiscoversRepositoryBestEffort(t *testing.T) {
@@ -30,6 +30,6 @@ func TestDoctorDiscoversRepositoryBestEffort(t *testing.T) {
require.NoError(t, Execute(context.Background(), deps, []string{"doctor", "--json=repo,repo_source"}))
require.JSONEq(t, `{"repo":"alice/project","repo_source":"remote origin"}`, out.String())
out.Reset()
deps.Getenv = envFunc(map[string]string{"TEA_HOST": server.URL})
deps.Getenv = envFunc(map[string]string{"GITEA_CLI_HOST": server.URL})
require.Equal(t, clierr.Authentication, clierr.ExitCode(Execute(context.Background(), deps, []string{"doctor"})))
}
+2 -2
View File
@@ -9,7 +9,7 @@ import (
"os"
"path/filepath"
"gitea.dev/tea/internal/clierr"
"gitea.dev/cli/internal/clierr"
"github.com/spf13/cobra"
)
@@ -23,7 +23,7 @@ func writeOutput(cmd *cobra.Command, output string, write func(io.Writer) error)
if output == "" || output == "-" {
return write(cmd.OutOrStdout())
}
file, err := os.CreateTemp(filepath.Dir(output), ".tea-download-*")
file, err := os.CreateTemp(filepath.Dir(output), ".gt-download-*")
if err != nil {
return err
}
+3 -3
View File
@@ -11,8 +11,8 @@ import (
"os"
"strings"
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/terminal"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/terminal"
"github.com/spf13/cobra"
)
@@ -36,7 +36,7 @@ func (a *application) editor() (terminal.Editor, string, error) {
return nil, "", err
}
if preferences.Editor == "" {
return nil, "", clierr.Wrap(clierr.Usage, errors.New("configure an editor using tea config set editor or EDITOR"))
return nil, "", clierr.Wrap(clierr.Usage, errors.New("configure an editor using gt config set editor or EDITOR"))
}
return a.deps.Editor, preferences.Editor, nil
}
+3 -3
View File
@@ -11,9 +11,9 @@ import (
"strings"
"testing"
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/services"
"gitea.dev/tea/internal/transport"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/services"
"gitea.dev/cli/internal/transport"
"github.com/stretchr/testify/require"
)
+1 -1
View File
@@ -7,7 +7,7 @@ import (
"context"
"io"
"gitea.dev/tea/internal/git"
"gitea.dev/cli/internal/git"
)
func (a *application) git(ctx context.Context, args ...string) (string, error) {
+9 -9
View File
@@ -9,11 +9,11 @@ import (
"path/filepath"
"strings"
"gitea.dev/tea/internal/auth"
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/git"
"gitea.dev/tea/internal/services"
"gitea.dev/tea/internal/settings"
"gitea.dev/cli/internal/auth"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/git"
"gitea.dev/cli/internal/services"
"gitea.dev/cli/internal/settings"
"github.com/spf13/cobra"
)
@@ -95,7 +95,7 @@ func (a *application) gitCredentialCommand() *cobra.Command {
}
}
if strings.ContainsAny(user+credential.AccessToken, "\x00\r\n") {
return clierr.Wrap(clierr.Authentication, errors.New("stored Git credential contains invalid protocol characters; run tea auth login"))
return clierr.Wrap(clierr.Authentication, errors.New("stored Git credential contains invalid protocol characters; run gt auth login"))
}
if err := cmd.Context().Err(); err != nil {
return err
@@ -107,7 +107,7 @@ func (a *application) gitCredentialCommand() *cobra.Command {
func (a *application) setupGitCommand() *cobra.Command {
var local bool
command := &cobra.Command{Use: "setup-git", Short: "Explicitly register tea as a scoped Git credential helper", Annotations: textOutput("setup-git configures Git"), Args: argsExact(0), RunE: func(cmd *cobra.Command, _ []string) error {
command := &cobra.Command{Use: "setup-git", Short: "Explicitly register gt as a scoped Git credential helper", Annotations: textOutput("setup-git configures Git"), Args: argsExact(0), RunE: func(cmd *cobra.Command, _ []string) error {
target, err := a.resolveTarget(cmd.Context(), false, false)
if err != nil {
return err
@@ -123,11 +123,11 @@ func (a *application) setupGitCommand() *cobra.Command {
return command
}
// credentialHelper locates tea's executable and absolute configuration directory for Git's credential helper.
// credentialHelper locates gt's executable and absolute configuration directory for Git's credential helper.
func (a *application) credentialHelper() (executable, configDir string, err error) {
executable, err = a.deps.Executable()
if err != nil {
return "", "", errors.New("cannot locate tea's executable for Git authentication")
return "", "", errors.New("cannot locate gt's executable for Git authentication")
}
configDir, err = filepath.Abs(a.deps.Settings.Dir)
if err != nil {
@@ -14,10 +14,10 @@ import (
"testing"
"time"
"gitea.dev/tea/internal/auth"
"gitea.dev/tea/internal/git"
"gitea.dev/tea/internal/services"
"gitea.dev/tea/internal/settings"
"gitea.dev/cli/internal/auth"
"gitea.dev/cli/internal/git"
"gitea.dev/cli/internal/services"
"gitea.dev/cli/internal/settings"
"github.com/stretchr/testify/require"
)
@@ -26,7 +26,7 @@ func TestGiteaGitCredentialHelperClonesPrivateRepository(t *testing.T) {
deps.Settings = settings.New(filepath.Join(t.TempDir(), "configuration with spaces"))
deps.Credentials.Dir = deps.Settings.Dir
var repo services.Repository
require.NoError(t, Execute(context.Background(), deps, []string{"repo", "create", fmt.Sprintf("tea-git-helper-%d", time.Now().UnixNano()), "--private", "--auto-init", "--json"}))
require.NoError(t, Execute(context.Background(), deps, []string{"repo", "create", fmt.Sprintf("gt-git-helper-%d", time.Now().UnixNano()), "--private", "--auto-init", "--json"}))
require.NoError(t, json.Unmarshal(out.Bytes(), &repo))
require.True(t, repo.Private)
t.Cleanup(func() {
@@ -38,7 +38,7 @@ func TestGiteaGitCredentialHelperClonesPrivateRepository(t *testing.T) {
require.NoError(t, testManager(t, deps).Register(gitea.url, user, "file", "token", auth.HostOptions{}, auth.Credential{AccessToken: gitea.token}))
binaryDir := filepath.Join(t.TempDir(), "binary with 'quote'")
require.NoError(t, os.MkdirAll(binaryDir, 0o700))
binary := filepath.Join(binaryDir, "tea")
binary := filepath.Join(binaryDir, "gt")
if os.PathSeparator == '\\' {
binary += ".exe"
}
@@ -58,17 +58,17 @@ func TestGiteaGitCredentialHelperClonesPrivateRepository(t *testing.T) {
environment = append(environment, entry)
}
globalConfig := filepath.Join(t.TempDir(), "gitconfig")
environment = append(environment, "GIT_CONFIG_GLOBAL="+globalConfig, "GIT_CONFIG_NOSYSTEM=1", "TEA_CONFIG_DIR="+deps.Settings.Dir, "GITEA_TOKEN=", "GITEA_INSTANCE_URL=", "TEA_HOST=", "TEA_USER=", "TEA_REPO=")
environment = append(environment, "GIT_CONFIG_GLOBAL="+globalConfig, "GIT_CONFIG_NOSYSTEM=1", "GITEA_CLI_CONFIG_DIR="+deps.Settings.Dir, "GITEA_TOKEN=", "GITEA_INSTANCE_URL=", "GITEA_CLI_HOST=", "GITEA_CLI_USER=", "GITEA_CLI_REPO=")
runner := git.System{Env: environment, ErrOut: diagnostics}
deps.Git = runner
_, anonymousErr := runner.Output(context.Background(), "", false, "-c", "credential.helper=", "clone", "--", repo.CloneURL, filepath.Join(t.TempDir(), "anonymous-clone"))
require.Error(t, anonymousErr, "private repository must reject an unauthenticated clone")
out.Reset()
diagnostics.Reset()
teaClone := filepath.Join(t.TempDir(), "tea-private-clone")
require.NoError(t, Execute(context.Background(), deps, []string{"repo", "clone", repo.FullName, teaClone, "--no-input", "--json=id"}))
gtClone := filepath.Join(t.TempDir(), "gt-private-clone")
require.NoError(t, Execute(context.Background(), deps, []string{"repo", "clone", repo.FullName, gtClone, "--no-input", "--json=id"}))
require.JSONEq(t, fmt.Sprintf(`{"id":%d}`, repo.ID), out.String())
_, localHelperErr := runner.Output(context.Background(), teaClone, false, "config", "--local", "--get-all", "credential."+gitea.url+".helper")
_, localHelperErr := runner.Output(context.Background(), gtClone, false, "config", "--local", "--get-all", "credential."+gitea.url+".helper")
var missingLocalHelper *git.CommandError
require.ErrorAs(t, localHelperErr, &missingLocalHelper)
require.Equal(t, 1, missingLocalHelper.ExitCode)
@@ -82,33 +82,33 @@ func TestGiteaGitCredentialHelperClonesPrivateRepository(t *testing.T) {
var pull services.Pull
require.NoError(t, json.Unmarshal(out.Bytes(), &pull))
out.Reset()
require.NoError(t, Execute(context.Background(), deps, []string{"pr", "checkout", fmt.Sprint(pull.Number), "-R", repo.FullName, "--cwd", teaClone, "--no-input", "--json"}))
require.NoError(t, Execute(context.Background(), deps, []string{"pr", "checkout", fmt.Sprint(pull.Number), "-R", repo.FullName, "--cwd", gtClone, "--no-input", "--json"}))
var checkout git.CheckoutResult
require.NoError(t, json.Unmarshal(out.Bytes(), &checkout))
require.Equal(t, pull.HeadSHA, checkout.Commit)
require.Equal(t, "pr/"+fmt.Sprint(pull.Number), checkout.Branch)
branchesBefore, err := runner.Output(context.Background(), teaClone, false, "for-each-ref", "--format=%(refname):%(objectname)", "refs/heads/")
branchesBefore, err := runner.Output(context.Background(), gtClone, false, "for-each-ref", "--format=%(refname):%(objectname)", "refs/heads/")
require.NoError(t, err)
out.Reset()
require.NoError(t, Execute(context.Background(), deps, []string{"pr", "checkout", fmt.Sprint(pull.Number), "-R", repo.FullName, "--cwd", teaClone, "--detach", "--no-input", "--json"}))
require.NoError(t, Execute(context.Background(), deps, []string{"pr", "checkout", fmt.Sprint(pull.Number), "-R", repo.FullName, "--cwd", gtClone, "--detach", "--no-input", "--json"}))
require.NoError(t, json.Unmarshal(out.Bytes(), &checkout))
require.True(t, checkout.Detached)
require.Empty(t, checkout.Branch)
require.Equal(t, pull.HeadSHA, checkout.Commit)
branchesAfter, err := runner.Output(context.Background(), teaClone, false, "for-each-ref", "--format=%(refname):%(objectname)", "refs/heads/")
branchesAfter, err := runner.Output(context.Background(), gtClone, false, "for-each-ref", "--format=%(refname):%(objectname)", "refs/heads/")
require.NoError(t, err)
require.Equal(t, branchesBefore, branchesAfter)
out.Reset()
require.NoError(t, Execute(context.Background(), deps, []string{"pr", "checkout", fmt.Sprint(pull.Number), "-R", repo.FullName, "--cwd", teaClone, "--no-input", "--json"}))
require.NoError(t, Execute(context.Background(), deps, []string{"pr", "checkout", fmt.Sprint(pull.Number), "-R", repo.FullName, "--cwd", gtClone, "--no-input", "--json"}))
require.NoError(t, json.Unmarshal(out.Bytes(), &checkout))
require.False(t, checkout.Detached)
require.Equal(t, "pr/"+fmt.Sprint(pull.Number), checkout.Branch)
branchesAfter, err = runner.Output(context.Background(), teaClone, false, "for-each-ref", "--format=%(refname):%(objectname)", "refs/heads/")
branchesAfter, err = runner.Output(context.Background(), gtClone, false, "for-each-ref", "--format=%(refname):%(objectname)", "refs/heads/")
require.NoError(t, err)
require.Equal(t, branchesBefore, branchesAfter)
_, err = runner.Output(context.Background(), teaClone, false, "switch", "--detach", pull.HeadSHA)
_, err = runner.Output(context.Background(), gtClone, false, "switch", "--detach", pull.HeadSHA)
require.NoError(t, err)
_, headErr := runner.Output(context.Background(), teaClone, false, "symbolic-ref", "--quiet", "HEAD")
_, headErr := runner.Output(context.Background(), gtClone, false, "symbolic-ref", "--quiet", "HEAD")
var detachedHead *git.CommandError
require.ErrorAs(t, headErr, &detachedHead)
require.Equal(t, 1, detachedHead.ExitCode)
@@ -118,26 +118,26 @@ func TestGiteaGitCredentialHelperClonesPrivateRepository(t *testing.T) {
require.NoError(t, Execute(context.Background(), deps, []string{"pr", "view", fmt.Sprint(pull.Number), "-R", repo.FullName, "--json"}))
require.NoError(t, json.Unmarshal(out.Bytes(), &pull))
out.Reset()
require.NoError(t, Execute(context.Background(), deps, []string{"pr", "checkout", fmt.Sprint(pull.Number), "-R", repo.FullName, "--cwd", teaClone, "--update", "--no-input", "--json"}))
require.NoError(t, Execute(context.Background(), deps, []string{"pr", "checkout", fmt.Sprint(pull.Number), "-R", repo.FullName, "--cwd", gtClone, "--update", "--no-input", "--json"}))
require.NoError(t, json.Unmarshal(out.Bytes(), &checkout))
require.Equal(t, pull.HeadSHA, checkout.Commit)
localHead, err := runner.Output(context.Background(), teaClone, false, "rev-parse", "HEAD")
localHead, err := runner.Output(context.Background(), gtClone, false, "rev-parse", "HEAD")
require.NoError(t, err)
require.Equal(t, pull.HeadSHA, localHead)
deps.Streams.In = strings.NewReader(fmt.Sprintf(`{"branch":%q,"content":"c3luYwo=","message":"Disposable sync fixture"}`, repo.DefaultBranch))
require.NoError(t, Execute(context.Background(), deps, []string{"api", "repos/" + repo.FullName + "/contents/sync.txt", "--input", "-"}))
out.Reset()
require.NoError(t, Execute(context.Background(), deps, []string{"repo", "sync", "-R", repo.FullName, "--cwd", teaClone, "--no-input", "--json=branch,commit,remote"}))
require.NoError(t, Execute(context.Background(), deps, []string{"repo", "sync", "-R", repo.FullName, "--cwd", gtClone, "--no-input", "--json=branch,commit,remote"}))
var synced git.SyncResult
require.NoError(t, json.Unmarshal(out.Bytes(), &synced))
require.Equal(t, repo.DefaultBranch, synced.Branch)
localHead, err = runner.Output(context.Background(), teaClone, false, "rev-parse", "HEAD")
localHead, err = runner.Output(context.Background(), gtClone, false, "rev-parse", "HEAD")
require.NoError(t, err)
require.Equal(t, synced.Commit, localHead)
contents, err := os.ReadFile(filepath.Join(teaClone, "sync.txt"))
contents, err := os.ReadFile(filepath.Join(gtClone, "sync.txt"))
require.NoError(t, err)
require.Equal(t, "sync\n", string(contents))
if endpoint := os.Getenv("GITEA_TEA_TEST_SSH_ENDPOINT"); endpoint != "" {
if endpoint := os.Getenv("GITEA_CLI_TEST_SSH_ENDPOINT"); endpoint != "" {
verifySSHCloneAndCheckout(t, deps, repo, pull, user, environment, endpoint)
}
// The per-operation helper does not create a global Git configuration file.
+3 -3
View File
@@ -10,8 +10,8 @@ import (
"strings"
"testing"
"gitea.dev/tea/internal/auth"
"gitea.dev/tea/internal/clierr"
"gitea.dev/cli/internal/auth"
"gitea.dev/cli/internal/clierr"
"github.com/stretchr/testify/require"
)
@@ -65,7 +65,7 @@ func TestGitCredentialEnvironmentTokenIsScopedAndNeverPersisted(t *testing.T) {
server := newAuthenticatedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { t.Fatalf("unexpected request %s", r.URL.Path) }))
defer server.Close()
deps, out, _ := testDeps(t)
deps.Getenv = envFunc(map[string]string{"TEA_HOST": server.URL, "GITEA_TOKEN": "environment-token"})
deps.Getenv = envFunc(map[string]string{"GITEA_CLI_HOST": server.URL, "GITEA_TOKEN": "environment-token"})
host := strings.TrimPrefix(server.URL, "http://")
deps.Streams.In = strings.NewReader("protocol=http\nhost=" + host + "\npath=alice/project.git\n\n")
require.NoError(t, Execute(context.Background(), deps, []string{"auth", "git-credential", "get"}))
+9 -9
View File
@@ -18,12 +18,12 @@ import (
"strings"
"testing"
"gitea.dev/tea/internal/auth"
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/git"
"gitea.dev/tea/internal/settings"
"gitea.dev/tea/internal/terminal"
"gitea.dev/tea/internal/transport"
"gitea.dev/cli/internal/auth"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/git"
"gitea.dev/cli/internal/settings"
"gitea.dev/cli/internal/terminal"
"gitea.dev/cli/internal/transport"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@@ -58,7 +58,7 @@ func envFunc(vars map[string]string) func(string) string {
// serverEnv authenticates against serverURL through the environment, plus extra variables.
func serverEnv(serverURL string, extra map[string]string) func(string) string {
vars := map[string]string{"TEA_HOST": serverURL, "GITEA_TOKEN": "token"}
vars := map[string]string{"GITEA_CLI_HOST": serverURL, "GITEA_TOKEN": "token"}
maps.Copy(vars, extra)
return envFunc(vars)
}
@@ -73,7 +73,7 @@ func requireUsageBeforeRequests(t *testing.T, want string, args ...string) {
}))
defer server.Close()
deps, out, diagnostics := testDeps(t)
deps.Getenv = serverEnv(server.URL, map[string]string{"TEA_REPO": "alice/project"})
deps.Getenv = serverEnv(server.URL, map[string]string{"GITEA_CLI_REPO": "alice/project"})
err := Execute(context.Background(), deps, args)
require.Equal(t, clierr.Usage, clierr.ExitCode(err), "%v", err)
require.ErrorContains(t, err, want)
@@ -214,7 +214,7 @@ func configureAccounts(t *testing.T, deps Dependencies, url, active string, user
}
}
// credentialCall returns the fakeGit key of a Git call authenticated through the tea credential helper.
// credentialCall returns the fakeGit key of a Git call authenticated through the gt credential helper.
func credentialCall(t *testing.T, deps Dependencies, host, user string, args ...string) string {
t.Helper()
executable, err := deps.Executable()
+2 -2
View File
@@ -8,8 +8,8 @@ import (
"fmt"
"strings"
"gitea.dev/tea/internal/settings"
"gitea.dev/tea/internal/terminal"
"gitea.dev/cli/internal/settings"
"gitea.dev/cli/internal/terminal"
"github.com/spf13/cobra"
)
+5 -5
View File
@@ -13,7 +13,7 @@ import (
"strings"
"testing"
"gitea.dev/tea/internal/terminal"
"gitea.dev/cli/internal/terminal"
"github.com/stretchr/testify/require"
)
@@ -110,17 +110,17 @@ func TestTeaPagerAndColorEnvironmentOverrides(t *testing.T) {
_, _ = w.Write([]byte(`[{"id":1,"name":"bug","color":"ff0000","description":""},{"id":2,"name":"docs","color":"00ff00","description":""}]`))
}))
defer server.Close()
env := map[string]string{"TEA_PAGER": "tea-pager", "PAGER": "generic-pager", "TEA_COLOR": "always"}
env := map[string]string{"GITEA_CLI_PAGER": "gt-pager", "PAGER": "generic-pager", "GITEA_CLI_COLOR": "always"}
deps, out, _, pager := pagedDeps(t, server.URL, env, "pager", "configured-pager", "color", "never")
require.NoError(t, Execute(context.Background(), deps, []string{"label", "list", "-R", "alice/project", "--no-input"}))
require.Equal(t, "tea-pager", pager.command)
require.Equal(t, "gt-pager", pager.command)
require.Contains(t, pager.input, "\x1b[38;2;255;0;0mbug\x1b[0m")
out.Reset()
require.NoError(t, Execute(context.Background(), deps, []string{"config", "get", "pager", "--show-source", "--json"}))
require.JSONEq(t, `{"pager":{"value":"tea-pager","source":"TEA_PAGER"}}`, out.String())
require.JSONEq(t, `{"pager":{"value":"gt-pager","source":"GITEA_CLI_PAGER"}}`, out.String())
out.Reset()
require.NoError(t, Execute(context.Background(), deps, []string{"config", "get", "color", "--show-source", "--json"}))
require.JSONEq(t, `{"color":{"value":"always","source":"TEA_COLOR"}}`, out.String())
require.JSONEq(t, `{"color":{"value":"always","source":"GITEA_CLI_COLOR"}}`, out.String())
}
func TestColorAutoUsesStdoutTTY(t *testing.T) {
+12 -12
View File
@@ -20,10 +20,10 @@ import (
"strings"
"testing"
"gitea.dev/tea/internal/git"
"gitea.dev/tea/internal/services"
"gitea.dev/tea/internal/settings"
"gitea.dev/tea/internal/terminal"
"gitea.dev/cli/internal/git"
"gitea.dev/cli/internal/services"
"gitea.dev/cli/internal/settings"
"gitea.dev/cli/internal/terminal"
"github.com/kballard/go-shellquote"
"github.com/stretchr/testify/require"
"golang.org/x/crypto/ssh"
@@ -36,7 +36,7 @@ type giteaTarget struct{ url, token string }
// dependencies authenticated against it that run the system Git binary.
func giteaDeps(t *testing.T) (giteaTarget, Dependencies, *bytes.Buffer, *bytes.Buffer) {
t.Helper()
instance, tokenFile := os.Getenv("GITEA_TEA_TEST_URL"), os.Getenv("GITEA_TEA_TEST_TOKEN_FILE")
instance, tokenFile := os.Getenv("GITEA_CLI_TEST_URL"), os.Getenv("GITEA_CLI_TEST_TOKEN_FILE")
if instance == "" || tokenFile == "" {
t.Skip("disposable Gitea environment is not configured")
}
@@ -48,7 +48,7 @@ func giteaDeps(t *testing.T) (giteaTarget, Dependencies, *bytes.Buffer, *bytes.B
}
func (g giteaTarget) env(token string) func(string) string {
return envFunc(map[string]string{"TEA_HOST": g.url, "GITEA_TOKEN": token})
return envFunc(map[string]string{"GITEA_CLI_HOST": g.url, "GITEA_TOKEN": token})
}
func readTokenFile(t *testing.T, path string) string {
@@ -108,7 +108,7 @@ func verifyEditorSubmission(t *testing.T, deps Dependencies, repository, number
out, diagnostics := &bytes.Buffer{}, &bytes.Buffer{}
deps.Streams.Out, deps.Streams.ErrOut = out, diagnostics
deps.Editor = terminal.SystemEditor{Directory: directory, Streams: deps.Streams}
deps.Getenv = withEnv(deps.Getenv, map[string]string{"TEA_EDITOR": shellquote.Join(program)})
deps.Getenv = withEnv(deps.Getenv, map[string]string{"GITEA_CLI_EDITOR": shellquote.Join(program)})
args := []string{"issue", "comment", "create", number}
if review {
args = []string{"pr", "review", number, "--event", "PENDING"}
@@ -130,7 +130,7 @@ func verifyEditorSubmission(t *testing.T, deps Dependencies, repository, number
t.Errorf("editor submission cleanup: %v", err)
}
}()
files, err := filepath.Glob(filepath.Join(directory, "tea-draft-*.md"))
files, err := filepath.Glob(filepath.Join(directory, "gt-draft-*.md"))
require.NoError(t, err)
require.Empty(t, files)
require.Empty(t, diagnostics.String())
@@ -149,7 +149,7 @@ func verifyBodyEditorIntegration(t *testing.T, deps Dependencies, group, reposit
}()
editor, path := newDraftEditor(t, "Edited server body")
deps.Editor = editor
deps.Getenv = withEnv(deps.Getenv, map[string]string{"TEA_EDITOR": "integration-editor"})
deps.Getenv = withEnv(deps.Getenv, map[string]string{"GITEA_CLI_EDITOR": "integration-editor"})
out.Reset()
require.NoError(t, Execute(context.Background(), deps, append(base, "--editor", "--json=body")))
require.Equal(t, "Original editor body", editor.initial)
@@ -164,7 +164,7 @@ func executeWithEditorIntegration(t *testing.T, deps Dependencies, initial, body
deps.Streams.Out, deps.Streams.ErrOut = out, diagnostics
editor, path := newDraftEditor(t, body)
deps.Editor = editor
deps.Getenv = withEnv(deps.Getenv, map[string]string{"TEA_EDITOR": "integration-editor"})
deps.Getenv = withEnv(deps.Getenv, map[string]string{"GITEA_CLI_EDITOR": "integration-editor"})
require.NoError(t, Execute(context.Background(), deps, append(args, "--editor", "--no-input", "--json")))
require.Equal(t, initial, editor.initial)
require.Equal(t, "integration-editor", editor.command)
@@ -227,7 +227,7 @@ func verifySSHCloneAndCheckout(t *testing.T, deps Dependencies, repo services.Re
directory := t.TempDir()
public, private, err := ed25519.GenerateKey(rand.Reader)
require.NoError(t, err)
block, err := ssh.MarshalPrivateKey(private, "disposable Tea SSH fixture")
block, err := ssh.MarshalPrivateKey(private, "disposable gitea-cli SSH fixture")
require.NoError(t, err)
keyFile := filepath.Join(directory, "key with spaces")
require.NoError(t, os.WriteFile(keyFile, pem.EncodeToMemory(block), 0o600))
@@ -265,7 +265,7 @@ func verifySSHCloneAndCheckout(t *testing.T, deps Dependencies, repo services.Re
}
env = append(env, "PATH="+directory+string(os.PathListSeparator)+os.Getenv("PATH"), "GIT_SSH_VARIANT=ssh")
deps.Git = git.System{Env: env, ErrOut: deps.Streams.ErrOut}
instance := deps.Getenv("TEA_HOST")
instance := deps.Getenv("GITEA_CLI_HOST")
require.NoError(t, deps.Settings.Update(settings.TargetHosts, func(s *settings.Snapshot) error {
h := s.Hosts.Hosts[instance]
h.SSHHost, h.GitProtocol = endpoint, "ssh"
+11 -11
View File
@@ -17,8 +17,8 @@ import (
"testing"
"time"
"gitea.dev/tea/internal/services"
"gitea.dev/tea/internal/transport"
"gitea.dev/cli/internal/services"
"gitea.dev/cli/internal/transport"
"github.com/stretchr/testify/require"
"golang.org/x/crypto/ssh"
)
@@ -27,7 +27,7 @@ func TestGiteaMetadataLifecycle(t *testing.T) {
_, deps, out, diagnostics := giteaDeps(t)
execute := outputExecutor(t, &deps, out, diagnostics)
adminUsername := fmt.Sprintf("tea-it-admin-%d", time.Now().UnixNano())
adminUsername := fmt.Sprintf("gt-it-admin-%d", time.Now().UnixNano())
var managedUser services.AdminUser
adminData := execute("admin", "user", "create", adminUsername, "--email", adminUsername+"@example.test", "--password", "local-admin-test-password", "--admin", "--restricted", "--prohibit-login", "--visibility", "limited", "--json")
require.NotContains(t, string(adminData), "local-admin-test-password")
@@ -60,7 +60,7 @@ func TestGiteaMetadataLifecycle(t *testing.T) {
require.Contains(t, managedUsers, managedUser)
execute("admin", "user", "delete", adminUsername, "--yes")
userDeleted = true
name := fmt.Sprintf("tea-it-%d", time.Now().UnixNano())
name := fmt.Sprintf("gt-it-%d", time.Now().UnixNano())
var repo services.Repository
require.NoError(t, json.Unmarshal(execute("repo", "create", name, "--auto-init", "--private", "--json"), &repo))
require.Equal(t, name, repo.Name)
@@ -78,7 +78,7 @@ func TestGiteaMetadataLifecycle(t *testing.T) {
require.Empty(t, repo.Website)
require.False(t, repo.Archived)
scoped := func(args ...string) []byte { return execute(append(args, "-R", repo.FullName, "--json")...) }
templateName := fmt.Sprintf("tea-template-%d", time.Now().UnixNano())
templateName := fmt.Sprintf("gt-template-%d", time.Now().UnixNano())
var template, generated services.Repository
require.NoError(t, json.Unmarshal(execute("repo", "create", templateName, "--as-template", "--auto-init", "--default-branch", "trunk", "--private", "--json"), &template))
t.Cleanup(func() {
@@ -87,7 +87,7 @@ func TestGiteaMetadataLifecycle(t *testing.T) {
}
})
require.True(t, template.Template)
generatedName := fmt.Sprintf("tea-generated-%d", time.Now().UnixNano())
generatedName := fmt.Sprintf("gt-generated-%d", time.Now().UnixNano())
require.NoError(t, json.Unmarshal(execute("repo", "create", generatedName, "--template", template.URL, "--private", "--copy-git-hooks=false", "--json"), &generated))
t.Cleanup(func() {
if err := Execute(context.Background(), deps, []string{"repo", "delete", "-R", generated.FullName, "--yes"}); err != nil {
@@ -105,8 +105,8 @@ func TestGiteaMetadataLifecycle(t *testing.T) {
execute("api", "user/starred/"+generated.FullName, "--method", "DELETE")
require.NoError(t, json.Unmarshal(execute("repo", "list", "--watched", "--limit", "1", "--page", "2", "--json"), &foundRepos))
require.Len(t, foundRepos, 1)
if serverRoot := os.Getenv("GITEA_TEA_TEST_REPOSITORY_ROOT"); serverRoot != "" {
migrationName := fmt.Sprintf("tea-migrated-%d", time.Now().UnixNano())
if serverRoot := os.Getenv("GITEA_CLI_TEST_REPOSITORY_ROOT"); serverRoot != "" {
migrationName := fmt.Sprintf("gt-migrated-%d", time.Now().UnixNano())
var migrated services.Repository
require.NoError(t, json.Unmarshal(execute("repo", "migrate", "--server-path", filepath.ToSlash(filepath.Join(serverRoot, repo.FullName+".git")), "--name", migrationName, "--private", "--json"), &migrated))
t.Cleanup(func() {
@@ -259,7 +259,7 @@ func TestGiteaMetadataLifecycle(t *testing.T) {
require.Equal(t, "[]\n", string(scoped("milestone", "issue", "list", ms)))
execute("milestone", "delete", ms, "-R", repo.FullName, "--yes")
require.Equal(t, "[]\n", string(scoped("wiki", "list")))
notifier := fmt.Sprintf("tea-notifier-%d", time.Now().UnixNano())
notifier := fmt.Sprintf("gt-notifier-%d", time.Now().UnixNano())
deps.Streams.In = bytes.NewBufferString(fmt.Sprintf(`{"username":%q,"password":"local-test-password!123","email":%q,"must_change_password":false}`, notifier, notifier+"@example.test"))
execute("api", "admin/users", "--input", "-")
t.Cleanup(func() {
@@ -363,7 +363,7 @@ func TestGiteaMetadataLifecycle(t *testing.T) {
require.Equal(t, "BUILD_TOKEN", secrets[0].Name)
execute("secret", "delete", "BUILD_TOKEN", "-R", repo.FullName, "--yes")
require.Equal(t, "[]\n", string(scoped("secret", "list")))
accountName := fmt.Sprintf("TEA_IT_%d", time.Now().UnixNano())
accountName := fmt.Sprintf("CLI_IT_%d", time.Now().UnixNano())
execute("variable", "set", accountName, "--account", "--value", "account value")
t.Cleanup(func() {
if err := Execute(context.Background(), deps, []string{"variable", "delete", accountName, "--account", "--yes"}); err != nil {
@@ -372,7 +372,7 @@ func TestGiteaMetadataLifecycle(t *testing.T) {
})
require.NoError(t, json.Unmarshal(execute("variable", "view", accountName, "--account", "--json"), &variable))
require.Equal(t, "account value", variable.Value)
orgName := fmt.Sprintf("tea-it-org-%d", time.Now().UnixNano())
orgName := fmt.Sprintf("gt-it-org-%d", time.Now().UnixNano())
var organization services.Organization
require.NoError(t, json.Unmarshal(execute("org", "create", orgName, "--description", "Original", "--visibility", "private", "--json"), &organization))
require.Equal(t, "private", organization.Visibility)
+3 -3
View File
@@ -10,9 +10,9 @@ import (
"strconv"
"strings"
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/services"
"gitea.dev/tea/internal/terminal"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/services"
"gitea.dev/cli/internal/terminal"
"github.com/spf13/cobra"
)
+1 -1
View File
@@ -9,7 +9,7 @@ import (
"net/http"
"testing"
"gitea.dev/tea/internal/clierr"
"gitea.dev/cli/internal/clierr"
"github.com/stretchr/testify/require"
)
+2 -2
View File
@@ -10,8 +10,8 @@ import (
"strings"
"testing"
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/services"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/services"
"github.com/stretchr/testify/require"
)
+1 -1
View File
@@ -10,7 +10,7 @@ import (
"testing"
"time"
"gitea.dev/tea/internal/terminal"
"gitea.dev/cli/internal/terminal"
"github.com/stretchr/testify/require"
)
+2 -2
View File
@@ -13,8 +13,8 @@ import (
"strings"
"testing"
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/terminal"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/terminal"
"github.com/stretchr/testify/require"
)
+5 -5
View File
@@ -9,9 +9,9 @@ import (
"strings"
"time"
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/services"
"gitea.dev/tea/internal/terminal"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/services"
"gitea.dev/cli/internal/terminal"
"github.com/spf13/cobra"
)
@@ -41,7 +41,7 @@ func (a *application) issueEditCommand() *cobra.Command {
if a.policy(snapshot).CanPrompt(a.deps.Streams) && a.deps.IssueEditForm != nil {
return a.editIssuesInteractively(cmd, numbers)
}
return clierr.Wrap(clierr.Usage, errors.New("supply an edit flag; see tea issue edit --help"))
return clierr.Wrap(clierr.Usage, errors.New("supply an edit flag; see gt issue edit --help"))
}
if useEditor && len(numbers) != 1 {
return clierr.Wrap(clierr.Usage, errors.New("--editor requires one issue"))
@@ -79,7 +79,7 @@ func (a *application) issueEditCommand() *cobra.Command {
return err
}
if opts == (services.IssueEdit{}) && !useEditor && !metadata.changed(cmd) && !cmd.Flags().Changed("milestone-name") {
return clierr.Wrap(clierr.Usage, errors.New("supply an edit flag; see tea issue edit --help"))
return clierr.Wrap(clierr.Usage, errors.New("supply an edit flag; see gt issue edit --help"))
}
target, err := a.resolve(cmd.Context(), true)
if err != nil {
+1 -1
View File
@@ -11,7 +11,7 @@ import (
"testing"
"time"
"gitea.dev/tea/internal/terminal"
"gitea.dev/cli/internal/terminal"
"github.com/stretchr/testify/require"
)
+2 -2
View File
@@ -9,7 +9,7 @@ import (
"testing"
"time"
"gitea.dev/tea/internal/clierr"
"gitea.dev/cli/internal/clierr"
"github.com/stretchr/testify/require"
)
@@ -124,6 +124,6 @@ func TestIssueListWithoutRepoPointsToSearch(t *testing.T) {
deps.Git = &fakeGit{}
err := Execute(context.Background(), deps, []string{"issue", "list", "--no-input"})
require.Equal(t, clierr.Usage, clierr.ExitCode(err))
require.ErrorContains(t, err, "tea search issue")
require.ErrorContains(t, err, "gt search issue")
require.Empty(t, out.String())
}
+4 -4
View File
@@ -12,9 +12,9 @@ import (
"strings"
"time"
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/services"
"gitea.dev/tea/internal/terminal"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/services"
"gitea.dev/cli/internal/terminal"
"github.com/spf13/cobra"
)
@@ -209,7 +209,7 @@ func (a *application) issueCommand() *cobra.Command {
target, err := a.resolve(cmd.Context(), true)
if err != nil {
if errors.Is(err, errRepositoryRequired) {
return clierr.Wrap(clierr.Usage, errors.New("repository required: use --repo owner/name, or tea search issue for instance-wide results"))
return clierr.Wrap(clierr.Usage, errors.New("repository required: use --repo owner/name, or gt search issue for instance-wide results"))
}
return err
}
+2 -2
View File
@@ -7,8 +7,8 @@ import (
"io"
"strings"
"gitea.dev/tea/internal/services"
"gitea.dev/tea/internal/terminal"
"gitea.dev/cli/internal/services"
"gitea.dev/cli/internal/terminal"
"github.com/spf13/cobra"
)
+2 -2
View File
@@ -11,8 +11,8 @@ import (
"regexp"
"strings"
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/services"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/services"
)
var labelColor = regexp.MustCompile(`^[0-9a-fA-F]{6}$`)
+1 -1
View File
@@ -14,7 +14,7 @@ import (
"strings"
"testing"
"gitea.dev/tea/internal/services"
"gitea.dev/cli/internal/services"
"github.com/stretchr/testify/require"
)
+3 -3
View File
@@ -9,7 +9,7 @@ import (
"strconv"
"time"
"gitea.dev/tea/internal/clierr"
"gitea.dev/cli/internal/clierr"
"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
)
@@ -24,7 +24,7 @@ func (a *application) manCommand() *cobra.Command {
root := NewRoot(Dependencies{})
target, remaining, err := root.Find(args)
if err != nil || len(remaining) != 0 {
return clierr.Wrap(clierr.Usage, errors.New("unknown manual command; use tea help to list commands"))
return clierr.Wrap(clierr.Usage, errors.New("unknown manual command; use gt help to list commands"))
}
date := ManualDate(a.deps.Getenv)
return writeOutput(cmd, output, func(writer io.Writer) error {
@@ -35,7 +35,7 @@ func (a *application) manCommand() *cobra.Command {
}
page.DisableAutoGenTag = true
// GenMan fills an empty Title from the command path by mutating the header, so each page needs its own.
header := &doc.GenManHeader{Section: "1", Date: &date, Source: "Tea", Manual: "Tea Manual"}
header := &doc.GenManHeader{Section: "1", Date: &date, Source: "gitea-cli", Manual: "gitea-cli Manual"}
if err := doc.GenMan(page, header, writer); err != nil {
return err
}
+6 -6
View File
@@ -9,7 +9,7 @@ import (
"path/filepath"
"testing"
"gitea.dev/tea/internal/clierr"
"gitea.dev/cli/internal/clierr"
"github.com/stretchr/testify/require"
)
@@ -21,7 +21,7 @@ func TestManWritesSelectedCommandWithoutReplacingFiles(t *testing.T) {
require.Empty(t, out.String())
data, err := os.ReadFile(path)
require.NoError(t, err)
require.Contains(t, string(data), "tea-pr-checkout")
require.Contains(t, string(data), "gt-pr-checkout")
require.Contains(t, string(data), "detach")
require.Equal(t, clierr.Usage, clierr.ExitCode(Execute(context.Background(), deps, args)))
after, err := os.ReadFile(path)
@@ -41,11 +41,11 @@ func TestManIncludesFullCommandTree(t *testing.T) {
deps, out, _ := testDeps(t)
require.NoError(t, Execute(context.Background(), deps, []string{"man"}))
manual := out.String()
for _, command := range []string{"tea-pr-checkout", "tea-issue-comment-create", "tea-auth-login", "tea-run-artifact-download"} {
for _, command := range []string{"gt-pr-checkout", "gt-issue-comment-create", "gt-auth-login", "gt-run-artifact-download"} {
require.Contains(t, manual, command)
}
require.Contains(t, manual, `.TH "TEA-PR-CHECKOUT" "1" "Jan 2026"`)
require.NotContains(t, manual, "tea-auth-git-credential")
require.Contains(t, manual, `.TH "GT-PR-CHECKOUT" "1" "Jan 2026"`)
require.NotContains(t, manual, "gt-auth-git-credential")
first := manual
out.Reset()
require.NoError(t, Execute(context.Background(), deps, []string{"man"}))
@@ -53,7 +53,7 @@ func TestManIncludesFullCommandTree(t *testing.T) {
out.Reset()
deps.Getenv = envFunc(map[string]string{"SOURCE_DATE_EPOCH": "1780000000"})
require.NoError(t, Execute(context.Background(), deps, []string{"man", "pr", "checkout"}))
require.Contains(t, out.String(), `.TH "TEA-PR-CHECKOUT" "1" "May 2026"`)
require.Contains(t, out.String(), `.TH "GT-PR-CHECKOUT" "1" "May 2026"`)
}
func TestCanceledManDoesNotPublishOutputFile(t *testing.T) {
+3 -3
View File
@@ -11,9 +11,9 @@ import (
"strings"
"time"
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/services"
"gitea.dev/tea/internal/terminal"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/services"
"gitea.dev/cli/internal/terminal"
"github.com/spf13/cobra"
)
+1 -1
View File
@@ -10,7 +10,7 @@ import (
"strings"
"testing"
"gitea.dev/tea/internal/clierr"
"gitea.dev/cli/internal/clierr"
"github.com/stretchr/testify/require"
)
+2 -2
View File
@@ -10,8 +10,8 @@ import (
"testing"
"time"
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/terminal"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/terminal"
"github.com/stretchr/testify/require"
)
+1 -1
View File
@@ -11,7 +11,7 @@ import (
"path/filepath"
"testing"
"gitea.dev/tea/internal/clierr"
"gitea.dev/cli/internal/clierr"
"github.com/stretchr/testify/require"
)
+2 -2
View File
@@ -9,8 +9,8 @@ import (
"strconv"
"strings"
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/services"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/services"
"github.com/spf13/cobra"
)
+2 -2
View File
@@ -6,8 +6,8 @@ package app
import (
"errors"
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/services"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/services"
"github.com/spf13/cobra"
)
+5 -5
View File
@@ -11,10 +11,10 @@ import (
"path/filepath"
"strings"
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/services"
"gitea.dev/tea/internal/settings"
"gitea.dev/tea/internal/terminal"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/services"
"gitea.dev/cli/internal/settings"
"gitea.dev/cli/internal/terminal"
"github.com/spf13/cobra"
)
@@ -169,7 +169,7 @@ func (a *application) addRepositoryMutations(group *cobra.Command) {
options.ActionsEnabled = &actionsEnabled
}
if options == (services.RepositoryEdit{}) {
return clierr.Wrap(clierr.Usage, errors.New("supply an edit flag; see tea repo edit --help"))
return clierr.Wrap(clierr.Usage, errors.New("supply an edit flag; see gt repo edit --help"))
}
t, err := a.resolve(cmd.Context(), true)
if err != nil {
+3 -3
View File
@@ -13,9 +13,9 @@ import (
"strings"
"time"
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/services"
"gitea.dev/tea/internal/terminal"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/services"
"gitea.dev/cli/internal/terminal"
"github.com/spf13/cobra"
)
+3 -3
View File
@@ -7,9 +7,9 @@ import (
"errors"
"strings"
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/services"
"gitea.dev/tea/internal/terminal"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/services"
"gitea.dev/cli/internal/terminal"
"github.com/spf13/cobra"
)
+3 -3
View File
@@ -12,7 +12,7 @@ import (
"testing"
"time"
"gitea.dev/tea/internal/clierr"
"gitea.dev/cli/internal/clierr"
"github.com/spf13/cobra"
"github.com/stretchr/testify/require"
)
@@ -36,7 +36,7 @@ func TestCommandsWithoutOutputRejectJSON(t *testing.T) {
for _, sub := range command.Commands() {
walk(sub)
}
if command.HasSubCommands() || command.Annotations["tea.text"] != "" {
if command.HasSubCommands() || command.Annotations["gt.text"] != "" {
return
}
path := strings.Fields(command.CommandPath())[1:]
@@ -49,7 +49,7 @@ func TestCommandsWithoutOutputRejectJSON(t *testing.T) {
args = append(args, prefix+strconv.Itoa(len(args)+1))
}
deps, out, _ := testDeps(t)
deps.Getenv = serverEnv(server.URL, map[string]string{"TEA_REPO": "alice/project"})
deps.Getenv = serverEnv(server.URL, map[string]string{"GITEA_CLI_REPO": "alice/project"})
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
err := Execute(ctx, deps, slices.Concat(path, args, []string{"--json", "--yes", "--no-input"}))
cancel()
+4 -4
View File
@@ -9,10 +9,10 @@ import (
"fmt"
"strings"
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/git"
"gitea.dev/tea/internal/services"
"gitea.dev/tea/internal/settings"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/git"
"gitea.dev/cli/internal/services"
"gitea.dev/cli/internal/settings"
"github.com/spf13/cobra"
)
+2 -2
View File
@@ -9,8 +9,8 @@ import (
"net/http"
"testing"
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/settings"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/settings"
"github.com/stretchr/testify/require"
)
+5 -5
View File
@@ -10,11 +10,11 @@ import (
"path/filepath"
"strings"
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/git"
"gitea.dev/tea/internal/services"
"gitea.dev/tea/internal/settings"
"gitea.dev/tea/internal/terminal"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/git"
"gitea.dev/cli/internal/services"
"gitea.dev/cli/internal/settings"
"gitea.dev/cli/internal/terminal"
"github.com/spf13/cobra"
)
+1 -1
View File
@@ -11,7 +11,7 @@ import (
"testing"
"time"
"gitea.dev/tea/internal/terminal"
"gitea.dev/cli/internal/terminal"
"github.com/stretchr/testify/require"
)
+2 -2
View File
@@ -12,8 +12,8 @@ import (
"strings"
"testing"
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/terminal"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/terminal"
"github.com/stretchr/testify/require"
)
+4 -4
View File
@@ -7,9 +7,9 @@ import (
"errors"
"strings"
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/services"
"gitea.dev/tea/internal/terminal"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/services"
"gitea.dev/cli/internal/terminal"
"github.com/spf13/cobra"
)
@@ -81,7 +81,7 @@ func (a *application) pullEditCommand() *cobra.Command {
opts.AllowMaintainerEdit = &maintainer
}
if opts == (services.PullEdit{}) && !useEditor && !draft && !ready && !metadata.changed(cmd) && !cmd.Flags().Changed("milestone-name") {
return clierr.Wrap(clierr.Usage, errors.New("supply an edit flag; see tea pr edit --help"))
return clierr.Wrap(clierr.Usage, errors.New("supply an edit flag; see gt pr edit --help"))
}
target, err := a.resolve(cmd.Context(), true)
if err != nil {
+10 -10
View File
@@ -14,9 +14,9 @@ import (
"testing"
"time"
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/git"
"gitea.dev/tea/internal/services"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/git"
"gitea.dev/cli/internal/services"
"github.com/stretchr/testify/require"
)
@@ -25,13 +25,13 @@ func TestGiteaPullEditLifecycle(t *testing.T) {
execute := outputExecutor(t, &deps, out, diagnostics)
out.Reset()
diagnostics.Reset()
identityErr := Execute(context.Background(), deps, []string{"issue", "create", "-R", "integration/nonexistent", "--title", "Must not submit", "--body", "Body", "--user", "tea-deliberately-wrong-account", "--no-input"})
identityErr := Execute(context.Background(), deps, []string{"issue", "create", "-R", "integration/nonexistent", "--title", "Must not submit", "--body", "Body", "--user", "gt-deliberately-wrong-account", "--no-input"})
require.ErrorContains(t, identityErr, "does not belong to the selected account")
require.Equal(t, clierr.Authentication, clierr.ExitCode(identityErr))
require.Empty(t, out.String())
require.Empty(t, diagnostics.String())
var repo services.Repository
name := fmt.Sprintf("tea-pr-edit-%d", time.Now().UnixNano())
name := fmt.Sprintf("gt-pr-edit-%d", time.Now().UnixNano())
require.NoError(t, json.Unmarshal(execute("repo", "create", name, "--auto-init", "--private", "--json"), &repo))
t.Cleanup(func() {
if err := Execute(context.Background(), deps, []string{"repo", "delete", "-R", repo.FullName, "--yes"}); err != nil {
@@ -119,7 +119,7 @@ func TestGiteaPullEditLifecycle(t *testing.T) {
require.Equal(t, pull.Number, filtered[0].Number)
require.Equal(t, strings.SplitN(repo.FullName, "/", 2)[0], filtered[0].Author)
require.NotEmpty(t, filtered[0].UpdatedAt)
require.NoError(t, json.Unmarshal(execute("pr", "list", "-R", repo.FullName, "--base", "tea-nonexistent-target-branch", "--json"), &filtered))
require.NoError(t, json.Unmarshal(execute("pr", "list", "-R", repo.FullName, "--base", "gt-nonexistent-target-branch", "--json"), &filtered))
require.Empty(t, filtered)
var head struct {
Head struct {
@@ -155,7 +155,7 @@ func TestGiteaPullEditLifecycle(t *testing.T) {
require.Equal(t, head.Head.SHA, actual)
execute("repo", "edit", "-R", repo.FullName, "--private=true")
for _, state := range []string{"failure", "success"} {
payload, err := json.Marshal(map[string]string{"state": state, "context": "tea-check", "description": "Disposable check"})
payload, err := json.Marshal(map[string]string{"state": state, "context": "gt-check", "description": "Disposable check"})
require.NoError(t, err)
deps.Streams.In = bytes.NewReader(payload)
execute("api", "repos/"+repo.FullName+"/statuses/"+head.Head.SHA, "--input", "-")
@@ -164,7 +164,7 @@ func TestGiteaPullEditLifecycle(t *testing.T) {
require.NoError(t, json.Unmarshal(execute("pr", "checks", n, "-R", repo.FullName, "--json"), &checks))
require.Len(t, checks, 1)
require.Equal(t, "success", checks[0].State)
require.Equal(t, "tea-check", checks[0].Name)
require.Equal(t, "gt-check", checks[0].Name)
require.NoError(t, json.Unmarshal(execute("pr", "edit", n, "-R", repo.FullName, "--set-labels", "repo:review", "--json"), &pull))
require.Equal(t, []services.Label{label}, pull.Labels)
require.NoError(t, json.Unmarshal(execute("pr", "edit", n, "-R", repo.FullName, "--set-labels=", "--json"), &pull))
@@ -255,7 +255,7 @@ func TestGiteaPullEditLifecycle(t *testing.T) {
verifyEditorSubmission(t, deps, repo.FullName, n, true)
require.Empty(t, out.String())
require.Contains(t, diagnostics.String(), "Deleted review")
if reviewerTokenFile := os.Getenv("GITEA_TEA_TEST_REVIEWER_TOKEN_FILE"); reviewerTokenFile != "" {
if reviewerTokenFile := os.Getenv("GITEA_CLI_TEST_REVIEWER_TOKEN_FILE"); reviewerTokenFile != "" {
reviewerDeps := deps
reviewerDeps.Getenv = gitea.env(readTokenFile(t, reviewerTokenFile))
out.Reset()
@@ -308,7 +308,7 @@ func TestGiteaPullEditLifecycle(t *testing.T) {
func testTeamReviewRequests(t *testing.T, deps *Dependencies, execute func(...string) []byte, reviewer string) {
t.Helper()
orgName := fmt.Sprintf("tea-review-org-%d", time.Now().UnixNano())
orgName := fmt.Sprintf("gt-review-org-%d", time.Now().UnixNano())
execute("org", "create", orgName, "--visibility", "private")
t.Cleanup(func() {
if err := Execute(context.Background(), *deps, []string{"org", "delete", orgName, "--yes"}); err != nil {
+1 -1
View File
@@ -8,7 +8,7 @@ import (
"net/http"
"testing"
"gitea.dev/tea/internal/terminal"
"gitea.dev/cli/internal/terminal"
"github.com/stretchr/testify/require"
)
+1 -1
View File
@@ -10,7 +10,7 @@ import (
"os"
"testing"
"gitea.dev/tea/internal/clierr"
"gitea.dev/cli/internal/clierr"
"github.com/stretchr/testify/require"
)
+3 -3
View File
@@ -13,9 +13,9 @@ import (
"strconv"
"strings"
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/services"
"gitea.dev/tea/internal/terminal"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/services"
"gitea.dev/cli/internal/terminal"
"github.com/spf13/cobra"
)
+1 -1
View File
@@ -12,7 +12,7 @@ import (
"strings"
"testing"
"gitea.dev/tea/internal/terminal"
"gitea.dev/cli/internal/terminal"
"github.com/stretchr/testify/require"
)
+3 -3
View File
@@ -8,9 +8,9 @@ import (
"fmt"
"strings"
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/services"
"gitea.dev/tea/internal/terminal"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/services"
"gitea.dev/cli/internal/terminal"
"github.com/spf13/cobra"
)
+2 -2
View File
@@ -4,8 +4,8 @@
package app
import (
"gitea.dev/tea/internal/clierr"
"gitea.dev/tea/internal/services"
"gitea.dev/cli/internal/clierr"
"gitea.dev/cli/internal/services"
"github.com/spf13/cobra"
)
+1 -1
View File
@@ -12,7 +12,7 @@ import (
"strings"
"testing"
"gitea.dev/tea/internal/clierr"
"gitea.dev/cli/internal/clierr"
"github.com/stretchr/testify/require"
)

Some files were not shown because too many files have changed in this diff Show More