This change enhances the 'issue' command functionality by enabling structured JSON
output for single issue views and introducing a method for output redirection.
**Changes Implemented:**
1. Enables the existing `--output json` flag for single issue commands (e.g., 'tea issue 17'). This flag was previously ignored in this context.
2. Introduces the new `--out <filename>` flag, which redirects the marshaled JSON output from stdout to the specified file.
Feeback more then welcome.
Co-authored-by: Jonas Toth <development@jonas-toth.eu>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/gitea/tea/pulls/841
Reviewed-by: TheFox0x7 <thefox0x7@noreply.gitea.com>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Riccardo Förster <riccardo.foerster@sarad.de>
Co-committed-by: Riccardo Förster <riccardo.foerster@sarad.de>
## Problem
Tea commands fail when run from git worktrees with the error:
Remote repository required: Specify ID via --repo or execute from a
local git repo.
Even though the worktree is in a valid git repository with remotes
configured.
Additionally, `tea pr create` was missing context validation, showing
cryptic errors like `"path segment [0]
is empty"` instead of helpful messages.
## Root Cause
1. **Worktree issue**: go-git's `PlainOpenWithOptions` was not
configured to read the `commondir` file that
git worktrees use. This file points to the main repository's `.git`
directory where remotes are actually
stored (worktrees don't have their own remotes).
2. **PR create issue**: Missing `ctx.Ensure()` validation meant errors
weren't caught early with clear
messages.
## Solution
### 1. Enable worktree support (`modules/git/repo.go`)
```go
EnableDotGitCommonDir: true, // Enable commondir support for worktrees
This tells go-git to:
- Read the commondir file in .git/worktrees/<name>/commondir
- Follow the reference (typically ../..) to the main repository
- Load remotes from the main repo's config
2. Add context validation (cmd/pulls/create.go)
ctx.Ensure(context.CtxRequirement{
LocalRepo: true,
RemoteRepo: true,
})
Provides clear error messages and matches the pattern used in pr
checkout (fixed in commit 0970b945 from
2020).
3. Add test coverage (modules/git/repo_test.go)
- Creates a real git repository with a worktree
- Verifies that RepoFromPath() can open the worktree
- Confirms that Config() correctly reads remotes from main repo
Test Results
Without fix:
❌ FAIL: Should NOT be empty, but was map[]
With fix:
✅ PASS: TestRepoFromPath_Worktree (0.12s)
Manual test in worktree:
cd /path/to/worktree
tea pr create --title "test"
# Now works! ✅
Checklist
- Tested manually in a git worktree
- Added test case that fails without the fix
- All existing tests pass
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/gitea/tea/pulls/850
Reviewed-by: techknowlogick <techknowlogick@noreply.gitea.com>
Co-authored-by: Brandon Martin <brandon@codedmart.com>
Co-committed-by: Brandon Martin <brandon@codedmart.com>
## Summary
This PR adds support for organization-level and global webhooks in the tea CLI tool.
## Changes Made
### Organization Webhooks
- Added `--org` flag to webhook commands to operate on organization-level webhooks
- Implemented full CRUD operations for org webhooks (create, list, update, delete)
- Extended TeaContext to support organization scope
### Global Webhooks
- Added `--global` flag with placeholder implementation
- Ready for when Gitea SDK adds global webhook API methods
### Technical Details
- Updated context handling to support org/global scopes
- Modified all webhook subcommands (create, list, update, delete)
- Maintained backward compatibility for repository webhooks
- Updated tests and documentation
## Usage Examples
```bash
# Repository webhooks (existing)
tea webhooks list
tea webhooks create https://example.com/hook --events push
# Organization webhooks (new)
tea webhooks list --org myorg
tea webhooks create https://example.com/hook --org myorg --events push,pull_request
# Global webhooks (future)
tea webhooks list --global
```
## Testing
- All existing tests pass
- Updated test expectations for new descriptions
- Manual testing of org webhook operations completed
Closes: webhook management feature request
Reviewed-on: https://gitea.com/gitea/tea/pulls/798
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Ross Golder <ross@golder.org>
Co-committed-by: Ross Golder <ross@golder.org>
[CLI.md](src/branch/main/docs/CLI.md) already gets generated using `urfave/cli-docs`. `cli-docs` can also generate man pages.
This change extends the doc generator to also generate a man page for `tea`.
* Add a subcommand to the doc generator to print the generated man page to stdout
Closes#777.
Co-authored-by: Valentin Brandl <mail@vbrandl.net>
Reviewed-on: https://gitea.com/gitea/tea/pulls/811
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: TheFox0x7 <thefox0x7@noreply.gitea.com>
Co-authored-by: Valentin Brandl <vbrandl@noreply.gitea.com>
Co-committed-by: Valentin Brandl <vbrandl@noreply.gitea.com>
This PR adds validation for the `--object-format` flag in the `repo create` command. The flag now accepts only `sha1` or `sha256` as valid values, and returns an error for any other value.
Changes:
- Added validation in `runRepoCreate` to check for valid object format values
- Added unit tests to verify the validation logic
- Fixed the field name from `ObjectFormat` to `ObjectFormatName` to match the SDK
The changes ensure that users get clear error messages when using invalid object format values, improving the user experience.
Fix#727Fix#660Fix#767
Co-authored-by: techknowlogick <techknowlogick@noreply.gitea.com>
Reviewed-on: https://gitea.com/gitea/tea/pulls/741
Reviewed-by: TheFox0x7 <thefox0x7@noreply.gitea.com>
It is very common to set `$EDITOR` to an terminal editor.
To do so, we have to attach the stdin and stdout to interact with it.
Otherwise the command would do nothing (when using `.Run()`) as it
silently fails or hang the command (using `.Start()`) because it waits
forever for input.
Also attaching stderr to make debugging easier if someone has a
non-compatible or broken `$EDITOR` set.
Reviewed-on: https://gitea.com/gitea/tea/pulls/706
Reviewed-by: Lunny Xiao <lunny@noreply.gitea.com>
Co-authored-by: Vincent Neubauer <v.neubauer@darlor.de>
Co-committed-by: Vincent Neubauer <v.neubauer@darlor.de>
Expose the --labels option for the `tea repos migrate` command. This pull request fixes the issue reported in gitea/tea#698
```bash
> tea ( main ) % ./tea repos migrate --help
NAME:
tea repos migrate - Migrate a repository
USAGE:
tea repos migrate [command options]
DESCRIPTION:
Migrate a repository and or mirror it.
OPTIONS:
--name value Name of the repository
--owner value Owner of the repository
--clone-url value Clone URL of the repository
--service value Service to migrate from. Supported services are: git, gitea, gitlab, gogs
--mirror Mirror the repository (default: false)
--private Make the repository private (default: false)
--template Make the repository a template (default: false)
--wiki Copy the wiki (default: false)
--issues Copy the issues (default: false)
--labels Copy the lables (default: false)
--pull-requests Copy the pull requests (default: false)
--releases Copy the releases (default: false)
--milestones Copy the milestones (default: false)
--mirror-interval value Interval to mirror the repository.
--lfs Copy the LFS objects (default: false)
--lfs-endpoint value LFS endpoint to use
--auth-user value Username to use for authentication.
--auth-password value Password to use for authentication.
--auth-token value Token to use for authentication.
--login value, -l value Use a different Gitea Login. Optional
--output value, -o value Output format. (simple, table, csv, tsv, yaml, json)
--help, -h show help
```
Fix tested successfully on an own migration from gitlab to gitea
This PR closesgitea/tea#698
Co-authored-by: ebner <simon.ebner@psi.ch>
Reviewed-on: https://gitea.com/gitea/tea/pulls/699
Reviewed-by: Lunny Xiao <lunny@noreply.gitea.com>
Co-authored-by: simongregorebner <simongregorebner@noreply.gitea.com>
Co-committed-by: simongregorebner <simongregorebner@noreply.gitea.com>
Add release asset management. This includes a series of subcommands under `tea release assets`:
- `tea release assets create <release-tag> <asset> [<asset>...]`: Upload one or more release attachments
- `tea release assets delete <release tag> <attachment name> [<attachment name>...]`: Delete one or more release attachments
- `tea release assets list <release tag>`: List Release Attachments
Co-authored-by: Dane Bouchie <dbouchie@iradimed.com>
Reviewed-on: https://gitea.com/gitea/tea/pulls/619
Co-authored-by: danebou <danebou@noreply.gitea.com>
Co-committed-by: danebou <danebou@noreply.gitea.com>
Hello,
This is a proposal to support consulting / protecting / unprotecting branches for a specific repository.
I copied the existing code for "issues" report and adapted to branches. There is no change of legacy code so I do not expect any impact.
Supported commands are "list", "protect", "unprotect":
- "List" print the list of branches with some available fields from gitea.Branch type.
- "protect" creates a gitea.BranchProtection with some default parameters for some specific branches
- "unprotect" destroys gitea.BranchProtection for some specific branches
What is printed now could be enriched with additional information gitea datatypes already offer.
Could you please evaluate this proposal?
I would be happy to receive any comment or remark to take into account.
**tea branches unprotect** --login opsi --repo opensky main
**tea branches list** --login opsi --repo opensky --fields name,protected,user-can-merge,user-can-push,protection
[name protected user-can-merge user-can-push protection]
+--------+-----------+----------------+---------------+------------+
| NAME | PROTECTED | USER-CAN-MERGE | USER-CAN-PUSH | PROTECTION |
+--------+-----------+----------------+---------------+------------+
| b_test | false | true | true | <None> |
| main | false | true | true | <None> |
+--------+-----------+----------------+---------------+------------+
**tea branches protect** --login opsi --repo opensky main
**tea branches list** --login opsi --repo opensky --fields name,protected,user-can-merge,user-can-push,protection
[name protected user-can-merge user-can-push protection]
+--------+-----------+----------------+---------------+----------------------+
| NAME | PROTECTED | USER-CAN-MERGE | USER-CAN-PUSH | PROTECTION |
+--------+-----------+----------------+---------------+----------------------+
| b_test | false | true | true | <None> |
| main | true | true | false | - enable-push: false |
| | | | | - approving: - |
| | | | | merging: - pushing: |
| | | | | |
+--------+-----------+----------------+---------------+----------------------+
Following commands run OK:
> make test
> make fmt
> make lint
Co-authored-by: Leonard Vimond <leonard.vimond.e@thalesdigital.io>
Co-authored-by: techknowlogick <techknowlogick@noreply.gitea.com>
Reviewed-on: https://gitea.com/gitea/tea/pulls/645
Reviewed-by: techknowlogick <techknowlogick@noreply.gitea.com>
Co-authored-by: leonard.vimond <leonard.vimond@noreply.gitea.com>
Co-committed-by: leonard.vimond <leonard.vimond@noreply.gitea.com>
commands now accept multiple arguments where it makes sense.
#### before
```
NAME:
tea issues close - Change state of an issue to 'closed'
USAGE:
tea issues close [command options] <issue index>
```
#### after
```
NAME:
tea issues close - Change state of one ore more issues to 'closed'
USAGE:
tea issues close [command options] <issue index> [<issue index>...]
```
Co-authored-by: Norwin <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/512
Reviewed-by: 6543 <6543@obermui.de>
Reviewed-by: justusbunsi <justusbunsi@noreply.gitea.io>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
This adds support for authentication using a SSH certificate and normal public keys when you've got an ssh-agent running that has this certificate or your public key loaded.
First question when creating a new login is to ask about the ssh certificates or public keys, when the answer is yes, we don't need to ask about tokens/usernames anymore.
Co-authored-by: Wim <wim@42.be>
Reviewed-on: https://gitea.com/gitea/tea/pulls/442
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: Wim <42wim@noreply.gitea.io>
Co-committed-by: Wim <42wim@noreply.gitea.io>
This changes the command help string from eg
```
NAME:
tea label create - Create a label
USAGE:
tea label [command options] [arguments...]
```
to
```
NAME:
tea label create - Create a label
USAGE:
tea label [command options]
```
Hopefully improving usability.
---
edit: this also changes `tea release create` to take the `--tag` flag value optionally via the first argument, as this seems to be a clear UX improvement.
fixes#483
Co-authored-by: Norwin <git@nroo.de>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/496
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
Reviewed-by: 6543 <6543@obermui.de>
Reviewed-by: delvh <delvh@noreply.gitea.io>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>