mirror of
https://gitea.com/gitea/tea.git
synced 2026-04-25 17:53:37 +02:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5103496232 | ||
|
|
a58c35c3e2 | ||
|
|
783ac7684a | ||
|
|
d0b7ea09e8 | ||
|
|
20914a1375 | ||
|
|
3c1c9b2904 |
@@ -39,7 +39,7 @@ jobs:
|
|||||||
make unit-test-coverage
|
make unit-test-coverage
|
||||||
services:
|
services:
|
||||||
gitea:
|
gitea:
|
||||||
image: docker.gitea.com/gitea:1.25.5
|
image: docker.gitea.com/gitea:1.26.0
|
||||||
cmd:
|
cmd:
|
||||||
- bash
|
- bash
|
||||||
- -c
|
- -c
|
||||||
|
|||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -17,3 +17,5 @@ dist/
|
|||||||
.direnv/
|
.direnv/
|
||||||
result
|
result
|
||||||
result-*
|
result-*
|
||||||
|
|
||||||
|
.DS_Store
|
||||||
@@ -61,11 +61,19 @@ func runReleaseAttachmentDelete(_ stdctx.Context, cmd *cli.Command) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
existing, _, err := client.ListReleaseAttachments(ctx.Owner, ctx.Repo, release.ID, gitea.ListReleaseAttachmentsOptions{
|
var existing []*gitea.Attachment
|
||||||
ListOptions: gitea.ListOptions{Page: -1},
|
for page := 1; ; {
|
||||||
})
|
page_attachments, resp, err := client.ListReleaseAttachments(ctx.Owner, ctx.Repo, release.ID, gitea.ListReleaseAttachmentsOptions{
|
||||||
if err != nil {
|
ListOptions: gitea.ListOptions{Page: page, PageSize: 50},
|
||||||
return err
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
existing = append(existing, page_attachments...)
|
||||||
|
if resp == nil || resp.NextPage == 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
page = resp.NextPage
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, name := range ctx.Args().Slice()[1:] {
|
for _, name := range ctx.Args().Slice()[1:] {
|
||||||
|
|||||||
19
cmd/pulls.go
19
cmd/pulls.go
@@ -109,11 +109,20 @@ func runPullDetail(_ stdctx.Context, cmd *cli.Command, index string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
reviews, _, err := client.ListPullReviews(ctx.Owner, ctx.Repo, idx, gitea.ListPullReviewsOptions{
|
var reviews []*gitea.PullReview
|
||||||
ListOptions: gitea.ListOptions{Page: -1},
|
for page := 1; ; {
|
||||||
})
|
page_reviews, resp, err := client.ListPullReviews(ctx.Owner, ctx.Repo, idx, gitea.ListPullReviewsOptions{
|
||||||
if err != nil {
|
ListOptions: gitea.ListOptions{Page: page, PageSize: 50},
|
||||||
fmt.Printf("error while loading reviews: %v\n", err)
|
})
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("error while loading reviews: %v\n", err)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
reviews = append(reviews, page_reviews...)
|
||||||
|
if resp == nil || resp.NextPage == 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
page = resp.NextPage
|
||||||
}
|
}
|
||||||
|
|
||||||
if ctx.IsSet("output") {
|
if ctx.IsSet("output") {
|
||||||
|
|||||||
@@ -11,19 +11,25 @@ import (
|
|||||||
|
|
||||||
// GetReleaseByTag finds a release by its tag name.
|
// GetReleaseByTag finds a release by its tag name.
|
||||||
func GetReleaseByTag(owner, repo, tag string, client *gitea.Client) (*gitea.Release, error) {
|
func GetReleaseByTag(owner, repo, tag string, client *gitea.Client) (*gitea.Release, error) {
|
||||||
rl, _, err := client.ListReleases(owner, repo, gitea.ListReleasesOptions{
|
for page := 1; ; {
|
||||||
ListOptions: gitea.ListOptions{Page: -1},
|
rl, resp, err := client.ListReleases(owner, repo, gitea.ListReleasesOptions{
|
||||||
})
|
ListOptions: gitea.ListOptions{Page: page, PageSize: 50},
|
||||||
if err != nil {
|
})
|
||||||
return nil, err
|
if err != nil {
|
||||||
}
|
return nil, err
|
||||||
if len(rl) == 0 {
|
|
||||||
return nil, fmt.Errorf("repo does not have any release")
|
|
||||||
}
|
|
||||||
for _, r := range rl {
|
|
||||||
if r.TagName == tag {
|
|
||||||
return r, nil
|
|
||||||
}
|
}
|
||||||
|
if page == 1 && len(rl) == 0 {
|
||||||
|
return nil, fmt.Errorf("repo does not have any release")
|
||||||
|
}
|
||||||
|
for _, r := range rl {
|
||||||
|
if r.TagName == tag {
|
||||||
|
return r, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if resp == nil || resp.NextPage == 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
page = resp.NextPage
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("release tag does not exist")
|
return nil, fmt.Errorf("release tag does not exist")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,13 +15,13 @@ import (
|
|||||||
"github.com/urfave/cli/v3"
|
"github.com/urfave/cli/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CmdRepos represents to login a gitea server.
|
// CmdRepos represents the command to manage repositories.
|
||||||
var CmdRepos = cli.Command{
|
var CmdRepos = cli.Command{
|
||||||
Name: "repos",
|
Name: "repos",
|
||||||
Aliases: []string{"repo"},
|
Aliases: []string{"repo"},
|
||||||
Category: catEntities,
|
Category: catEntities,
|
||||||
Usage: "Show repository details",
|
Usage: "Manage repositories",
|
||||||
Description: "Show repository details",
|
Description: "Manage repositories",
|
||||||
ArgsUsage: "[<repo owner>/<repo name>]",
|
ArgsUsage: "[<repo owner>/<repo name>]",
|
||||||
Action: runRepos,
|
Action: runRepos,
|
||||||
Commands: []*cli.Command{
|
Commands: []*cli.Command{
|
||||||
|
|||||||
@@ -1065,7 +1065,7 @@ Delete users Organizations
|
|||||||
|
|
||||||
## repos, repo
|
## repos, repo
|
||||||
|
|
||||||
Show repository details
|
Manage repositories
|
||||||
|
|
||||||
**--fields, -f**="": Comma-separated list of fields to print. Available values:
|
**--fields, -f**="": Comma-separated list of fields to print. Available values:
|
||||||
description,forks,id,name,owner,stars,ssh,updated,url,permission,type
|
description,forks,id,name,owner,stars,ssh,updated,url,permission,type
|
||||||
|
|||||||
6
go.mod
6
go.mod
@@ -5,7 +5,7 @@ go 1.26
|
|||||||
require (
|
require (
|
||||||
charm.land/glamour/v2 v2.0.0
|
charm.land/glamour/v2 v2.0.0
|
||||||
charm.land/huh/v2 v2.0.3
|
charm.land/huh/v2 v2.0.3
|
||||||
charm.land/lipgloss/v2 v2.0.2
|
charm.land/lipgloss/v2 v2.0.3
|
||||||
code.gitea.io/gitea-vet v0.2.3
|
code.gitea.io/gitea-vet v0.2.3
|
||||||
code.gitea.io/sdk/gitea v0.24.1
|
code.gitea.io/sdk/gitea v0.24.1
|
||||||
gitea.com/noerw/unidiff-comments v0.0.0-20220822113322-50f4daa0e35c
|
gitea.com/noerw/unidiff-comments v0.0.0-20220822113322-50f4daa0e35c
|
||||||
@@ -13,7 +13,7 @@ require (
|
|||||||
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de
|
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de
|
||||||
github.com/enescakir/emoji v1.0.0
|
github.com/enescakir/emoji v1.0.0
|
||||||
github.com/go-authgate/sdk-go v0.6.1
|
github.com/go-authgate/sdk-go v0.6.1
|
||||||
github.com/go-git/go-git/v5 v5.17.2
|
github.com/go-git/go-git/v5 v5.18.0
|
||||||
github.com/muesli/termenv v0.16.0
|
github.com/muesli/termenv v0.16.0
|
||||||
github.com/olekukonko/tablewriter v1.1.4
|
github.com/olekukonko/tablewriter v1.1.4
|
||||||
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
|
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
|
||||||
@@ -42,7 +42,7 @@ require (
|
|||||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||||
github.com/charmbracelet/colorprofile v0.4.3 // indirect
|
github.com/charmbracelet/colorprofile v0.4.3 // indirect
|
||||||
github.com/charmbracelet/ultraviolet v0.0.0-20260330092749-0f94982c930b // indirect
|
github.com/charmbracelet/ultraviolet v0.0.0-20260330092749-0f94982c930b // indirect
|
||||||
github.com/charmbracelet/x/ansi v0.11.6 // indirect
|
github.com/charmbracelet/x/ansi v0.11.7 // indirect
|
||||||
github.com/charmbracelet/x/exp/ordered v0.1.0 // indirect
|
github.com/charmbracelet/x/exp/ordered v0.1.0 // indirect
|
||||||
github.com/charmbracelet/x/exp/slice v0.0.0-20260406091427-a791e22d5143 // indirect
|
github.com/charmbracelet/x/exp/slice v0.0.0-20260406091427-a791e22d5143 // indirect
|
||||||
github.com/charmbracelet/x/exp/strings v0.1.0 // indirect
|
github.com/charmbracelet/x/exp/strings v0.1.0 // indirect
|
||||||
|
|||||||
6
go.sum
6
go.sum
@@ -8,6 +8,8 @@ charm.land/huh/v2 v2.0.3 h1:2cJsMqEPwSywGHvdlKsJyQKPtSJLVnFKyFbsYZTlLkU=
|
|||||||
charm.land/huh/v2 v2.0.3/go.mod h1:93eEveeeqn47MwiC3tf+2atZ2l7Is88rAtmZNZ8x9Wc=
|
charm.land/huh/v2 v2.0.3/go.mod h1:93eEveeeqn47MwiC3tf+2atZ2l7Is88rAtmZNZ8x9Wc=
|
||||||
charm.land/lipgloss/v2 v2.0.2 h1:xFolbF8JdpNkM2cEPTfXEcW1p6NRzOWTSamRfYEw8cs=
|
charm.land/lipgloss/v2 v2.0.2 h1:xFolbF8JdpNkM2cEPTfXEcW1p6NRzOWTSamRfYEw8cs=
|
||||||
charm.land/lipgloss/v2 v2.0.2/go.mod h1:KjPle2Qd3YmvP1KL5OMHiHysGcNwq6u83MUjYkFvEkM=
|
charm.land/lipgloss/v2 v2.0.2/go.mod h1:KjPle2Qd3YmvP1KL5OMHiHysGcNwq6u83MUjYkFvEkM=
|
||||||
|
charm.land/lipgloss/v2 v2.0.3 h1:yM2zJ4Cf5Y51b7RHIwioil4ApI/aypFXXVHSwlM6RzU=
|
||||||
|
charm.land/lipgloss/v2 v2.0.3/go.mod h1:7myLU9iG/3xluAWzpY/fSxYYHCgoKTie7laxk6ATwXA=
|
||||||
code.gitea.io/gitea-vet v0.2.3 h1:gdFmm6WOTM65rE8FUBTRzeQZYzXePKSSB1+r574hWwI=
|
code.gitea.io/gitea-vet v0.2.3 h1:gdFmm6WOTM65rE8FUBTRzeQZYzXePKSSB1+r574hWwI=
|
||||||
code.gitea.io/gitea-vet v0.2.3/go.mod h1:zcNbT/aJEmivCAhfmkHOlT645KNOf9W2KnkLgFjGGfE=
|
code.gitea.io/gitea-vet v0.2.3/go.mod h1:zcNbT/aJEmivCAhfmkHOlT645KNOf9W2KnkLgFjGGfE=
|
||||||
code.gitea.io/sdk/gitea v0.24.1 h1:hpaqcdGcBmfMpV7JSbBJVwE99qo+WqGreJYKrDKEyW8=
|
code.gitea.io/sdk/gitea v0.24.1 h1:hpaqcdGcBmfMpV7JSbBJVwE99qo+WqGreJYKrDKEyW8=
|
||||||
@@ -57,6 +59,8 @@ github.com/charmbracelet/ultraviolet v0.0.0-20260330092749-0f94982c930b h1:ASDO9
|
|||||||
github.com/charmbracelet/ultraviolet v0.0.0-20260330092749-0f94982c930b/go.mod h1:Vo8TffMf0q7Uho/n8e6XpBZvOWtd3g39yX+9P5rRutA=
|
github.com/charmbracelet/ultraviolet v0.0.0-20260330092749-0f94982c930b/go.mod h1:Vo8TffMf0q7Uho/n8e6XpBZvOWtd3g39yX+9P5rRutA=
|
||||||
github.com/charmbracelet/x/ansi v0.11.6 h1:GhV21SiDz/45W9AnV2R61xZMRri5NlLnl6CVF7ihZW8=
|
github.com/charmbracelet/x/ansi v0.11.6 h1:GhV21SiDz/45W9AnV2R61xZMRri5NlLnl6CVF7ihZW8=
|
||||||
github.com/charmbracelet/x/ansi v0.11.6/go.mod h1:2JNYLgQUsyqaiLovhU2Rv/pb8r6ydXKS3NIttu3VGZQ=
|
github.com/charmbracelet/x/ansi v0.11.6/go.mod h1:2JNYLgQUsyqaiLovhU2Rv/pb8r6ydXKS3NIttu3VGZQ=
|
||||||
|
github.com/charmbracelet/x/ansi v0.11.7 h1:kzv1kJvjg2S3r9KHo8hDdHFQLEqn4RBCb39dAYC84jI=
|
||||||
|
github.com/charmbracelet/x/ansi v0.11.7/go.mod h1:9qGpnAVYz+8ACONkZBUWPtL7lulP9No6p1epAihUZwQ=
|
||||||
github.com/charmbracelet/x/conpty v0.1.1 h1:s1bUxjoi7EpqiXysVtC+a8RrvPPNcNvAjfi4jxsAuEs=
|
github.com/charmbracelet/x/conpty v0.1.1 h1:s1bUxjoi7EpqiXysVtC+a8RrvPPNcNvAjfi4jxsAuEs=
|
||||||
github.com/charmbracelet/x/conpty v0.1.1/go.mod h1:OmtR77VODEFbiTzGE9G1XiRJAga6011PIm4u5fTNZpk=
|
github.com/charmbracelet/x/conpty v0.1.1/go.mod h1:OmtR77VODEFbiTzGE9G1XiRJAga6011PIm4u5fTNZpk=
|
||||||
github.com/charmbracelet/x/errors v0.0.0-20240508181413-e8d8b6e2de86 h1:JSt3B+U9iqk37QUU2Rvb6DSBYRLtWqFqfxf8l5hOZUA=
|
github.com/charmbracelet/x/errors v0.0.0-20240508181413-e8d8b6e2de86 h1:JSt3B+U9iqk37QUU2Rvb6DSBYRLtWqFqfxf8l5hOZUA=
|
||||||
@@ -122,6 +126,8 @@ github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMj
|
|||||||
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII=
|
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII=
|
||||||
github.com/go-git/go-git/v5 v5.17.2 h1:B+nkdlxdYrvyFK4GPXVU8w1U+YkbsgciIR7f2sZJ104=
|
github.com/go-git/go-git/v5 v5.17.2 h1:B+nkdlxdYrvyFK4GPXVU8w1U+YkbsgciIR7f2sZJ104=
|
||||||
github.com/go-git/go-git/v5 v5.17.2/go.mod h1:pW/VmeqkanRFqR6AljLcs7EA7FbZaN5MQqO7oZADXpo=
|
github.com/go-git/go-git/v5 v5.17.2/go.mod h1:pW/VmeqkanRFqR6AljLcs7EA7FbZaN5MQqO7oZADXpo=
|
||||||
|
github.com/go-git/go-git/v5 v5.18.0 h1:O831KI+0PR51hM2kep6T8k+w0/LIAD490gvqMCvL5hM=
|
||||||
|
github.com/go-git/go-git/v5 v5.18.0/go.mod h1:pW/VmeqkanRFqR6AljLcs7EA7FbZaN5MQqO7oZADXpo=
|
||||||
github.com/goccy/go-json v0.10.6 h1:p8HrPJzOakx/mn/bQtjgNjdTcN+/S6FcG2CTtQOrHVU=
|
github.com/goccy/go-json v0.10.6 h1:p8HrPJzOakx/mn/bQtjgNjdTcN+/S6FcG2CTtQOrHVU=
|
||||||
github.com/goccy/go-json v0.10.6/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
github.com/goccy/go-json v0.10.6/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
||||||
github.com/godbus/dbus/v5 v5.2.2 h1:TUR3TgtSVDmjiXOgAAyaZbYmIeP3DPkld3jgKGV8mXQ=
|
github.com/godbus/dbus/v5 v5.2.2 h1:TUR3TgtSVDmjiXOgAAyaZbYmIeP3DPkld3jgKGV8mXQ=
|
||||||
|
|||||||
@@ -83,6 +83,8 @@ func InitCommand(cmd *cli.Command) (*TeaContext, error) {
|
|||||||
}
|
}
|
||||||
if repoFlagPathExists {
|
if repoFlagPathExists {
|
||||||
repoPath = repoFlag
|
repoPath = repoFlag
|
||||||
|
} else {
|
||||||
|
c.RepoSlug = repoFlag
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,12 +92,6 @@ func InitCommand(cmd *cli.Command) (*TeaContext, error) {
|
|||||||
remoteFlag = config.GetPreferences().FlagDefaults.Remote
|
remoteFlag = config.GetPreferences().FlagDefaults.Remote
|
||||||
}
|
}
|
||||||
|
|
||||||
if repoPath == "" {
|
|
||||||
if repoPath, err = os.Getwd(); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create env login before repo context detection so it participates in remote URL matching
|
// Create env login before repo context detection so it participates in remote URL matching
|
||||||
var extraLogins []config.Login
|
var extraLogins []config.Login
|
||||||
envLogin := GetLoginByEnvVar()
|
envLogin := GetLoginByEnvVar()
|
||||||
@@ -108,17 +104,20 @@ func InitCommand(cmd *cli.Command) (*TeaContext, error) {
|
|||||||
|
|
||||||
// try to read local git repo & extract context: if repoFlag specifies a valid path, read repo in that dir,
|
// try to read local git repo & extract context: if repoFlag specifies a valid path, read repo in that dir,
|
||||||
// otherwise attempt PWD. if no repo is found, continue with default login
|
// otherwise attempt PWD. if no repo is found, continue with default login
|
||||||
if c.LocalRepo, c.Login, c.RepoSlug, err = contextFromLocalRepo(repoPath, remoteFlag, extraLogins); err != nil {
|
if c.RepoSlug == "" {
|
||||||
if err == errNotAGiteaRepo || err == gogit.ErrRepositoryNotExists {
|
if repoPath == "" {
|
||||||
// we can deal with that, commands needing the optional values use ctx.Ensure()
|
if repoPath, err = os.Getwd(); err != nil {
|
||||||
} else {
|
return nil, err
|
||||||
return nil, err
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if len(repoFlag) != 0 && !repoFlagPathExists {
|
if c.LocalRepo, c.Login, c.RepoSlug, err = contextFromLocalRepo(repoPath, remoteFlag, extraLogins); err != nil {
|
||||||
// if repoFlag is not a valid path, use it to override repoSlug
|
if err == errNotAGiteaRepo || err == gogit.ErrRepositoryNotExists {
|
||||||
c.RepoSlug = repoFlag
|
// we can deal with that, commands needing the optional values use ctx.Ensure()
|
||||||
|
} else {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If env vars are set, always use the env login (but repo slug was already
|
// If env vars are set, always use the env login (but repo slug was already
|
||||||
|
|||||||
@@ -4,9 +4,14 @@
|
|||||||
package context
|
package context
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"code.gitea.io/tea/modules/config"
|
"code.gitea.io/tea/modules/config"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
"github.com/urfave/cli/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_MatchLogins(t *testing.T) {
|
func Test_MatchLogins(t *testing.T) {
|
||||||
@@ -65,3 +70,47 @@ func Test_MatchLogins(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestInitCommand_WithRepoSlugSkipsLocalRepoDetection(t *testing.T) {
|
||||||
|
tmpDir := t.TempDir()
|
||||||
|
config.SetConfigForTesting(config.LocalConfig{
|
||||||
|
Logins: []config.Login{{
|
||||||
|
Name: "test-login",
|
||||||
|
URL: "https://gitea.example.com",
|
||||||
|
Token: "token",
|
||||||
|
User: "login-user",
|
||||||
|
Default: true,
|
||||||
|
}},
|
||||||
|
})
|
||||||
|
|
||||||
|
cmd := exec.Command("git", "init", "--object-format=sha256", tmpDir)
|
||||||
|
cmd.Env = os.Environ()
|
||||||
|
require.NoError(t, cmd.Run())
|
||||||
|
|
||||||
|
oldWd, err := os.Getwd()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NoError(t, os.Chdir(tmpDir))
|
||||||
|
t.Cleanup(func() {
|
||||||
|
require.NoError(t, os.Chdir(oldWd))
|
||||||
|
})
|
||||||
|
|
||||||
|
cliCmd := cli.Command{
|
||||||
|
Name: "branches",
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
&cli.StringFlag{Name: "login"},
|
||||||
|
&cli.StringFlag{Name: "repo"},
|
||||||
|
&cli.StringFlag{Name: "remote"},
|
||||||
|
&cli.StringFlag{Name: "output"},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
require.NoError(t, cliCmd.Set("repo", "owner/repo"))
|
||||||
|
|
||||||
|
ctx, err := InitCommand(&cliCmd)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, "owner", ctx.Owner)
|
||||||
|
require.Equal(t, "repo", ctx.Repo)
|
||||||
|
require.Equal(t, "owner/repo", ctx.RepoSlug)
|
||||||
|
require.Nil(t, ctx.LocalRepo)
|
||||||
|
require.NotNil(t, ctx.Login)
|
||||||
|
require.Equal(t, "test-login", ctx.Login.Name)
|
||||||
|
}
|
||||||
|
|||||||
@@ -180,19 +180,25 @@ func fetchIssueSelectables(login *config.Login, owner, repo string, done chan is
|
|||||||
r.MilestoneList[i] = m.Title
|
r.MilestoneList[i] = m.Title
|
||||||
}
|
}
|
||||||
|
|
||||||
labels, _, err := c.ListRepoLabels(owner, repo, gitea.ListLabelsOptions{
|
|
||||||
ListOptions: gitea.ListOptions{Page: -1},
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
r.Err = err
|
|
||||||
done <- r
|
|
||||||
return
|
|
||||||
}
|
|
||||||
r.LabelMap = make(map[string]int64)
|
r.LabelMap = make(map[string]int64)
|
||||||
r.LabelList = make([]string, len(labels))
|
r.LabelList = make([]string, 0)
|
||||||
for i, l := range labels {
|
for page := 1; ; {
|
||||||
r.LabelMap[l.Name] = l.ID
|
labels, resp, err := c.ListRepoLabels(owner, repo, gitea.ListLabelsOptions{
|
||||||
r.LabelList[i] = l.Name
|
ListOptions: gitea.ListOptions{Page: page, PageSize: 50},
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
r.Err = err
|
||||||
|
done <- r
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, l := range labels {
|
||||||
|
r.LabelMap[l.Name] = l.ID
|
||||||
|
r.LabelList = append(r.LabelList, l.Name)
|
||||||
|
}
|
||||||
|
if resp == nil || resp.NextPage == 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
page = resp.NextPage
|
||||||
}
|
}
|
||||||
|
|
||||||
done <- r
|
done <- r
|
||||||
|
|||||||
@@ -13,16 +13,23 @@ import (
|
|||||||
// ResolveLabelNames returns a list of label IDs for a given list of label names
|
// ResolveLabelNames returns a list of label IDs for a given list of label names
|
||||||
func ResolveLabelNames(client *gitea.Client, owner, repo string, labelNames []string) ([]int64, error) {
|
func ResolveLabelNames(client *gitea.Client, owner, repo string, labelNames []string) ([]int64, error) {
|
||||||
labelIDs := make([]int64, 0, len(labelNames))
|
labelIDs := make([]int64, 0, len(labelNames))
|
||||||
labels, _, err := client.ListRepoLabels(owner, repo, gitea.ListLabelsOptions{
|
page := 1
|
||||||
ListOptions: gitea.ListOptions{Page: -1},
|
for {
|
||||||
})
|
labels, resp, err := client.ListRepoLabels(owner, repo, gitea.ListLabelsOptions{
|
||||||
if err != nil {
|
ListOptions: gitea.ListOptions{Page: page, PageSize: 50},
|
||||||
return nil, err
|
})
|
||||||
}
|
if err != nil {
|
||||||
for _, l := range labels {
|
return nil, err
|
||||||
if utils.Contains(labelNames, l.Name) {
|
|
||||||
labelIDs = append(labelIDs, l.ID)
|
|
||||||
}
|
}
|
||||||
|
for _, l := range labels {
|
||||||
|
if utils.Contains(labelNames, l.Name) {
|
||||||
|
labelIDs = append(labelIDs, l.ID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if resp == nil || resp.NextPage == 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
page = resp.NextPage
|
||||||
}
|
}
|
||||||
return labelIDs, nil
|
return labelIDs, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,11 +166,19 @@ func generateToken(login config.Login, user, pass, otp, scopes string) (string,
|
|||||||
}
|
}
|
||||||
client := login.Client(opts...)
|
client := login.Client(opts...)
|
||||||
|
|
||||||
tl, _, err := client.ListAccessTokens(gitea.ListAccessTokensOptions{
|
var tl []*gitea.AccessToken
|
||||||
ListOptions: gitea.ListOptions{Page: -1},
|
for page := 1; ; {
|
||||||
})
|
page_tokens, resp, err := client.ListAccessTokens(gitea.ListAccessTokensOptions{
|
||||||
if err != nil {
|
ListOptions: gitea.ListOptions{Page: page, PageSize: 50},
|
||||||
return "", err
|
})
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
tl = append(tl, page_tokens...)
|
||||||
|
if resp == nil || resp.NextPage == 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
page = resp.NextPage
|
||||||
}
|
}
|
||||||
host, _ := os.Hostname()
|
host, _ := os.Hostname()
|
||||||
tokenName := host + "-tea"
|
tokenName := host + "-tea"
|
||||||
|
|||||||
@@ -19,11 +19,22 @@ import (
|
|||||||
// a matching private key in ~/.ssh/. If no match is found, path is empty.
|
// a matching private key in ~/.ssh/. If no match is found, path is empty.
|
||||||
func findSSHKey(client *gitea.Client) (string, error) {
|
func findSSHKey(client *gitea.Client) (string, error) {
|
||||||
// get keys registered on gitea instance
|
// get keys registered on gitea instance
|
||||||
keys, _, err := client.ListMyPublicKeys(gitea.ListPublicKeysOptions{
|
var keys []*gitea.PublicKey
|
||||||
ListOptions: gitea.ListOptions{Page: -1},
|
for page := 1; ; {
|
||||||
})
|
page_keys, resp, err := client.ListMyPublicKeys(gitea.ListPublicKeysOptions{
|
||||||
if err != nil || len(keys) == 0 {
|
ListOptions: gitea.ListOptions{Page: page, PageSize: 50},
|
||||||
return "", err
|
})
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
keys = append(keys, page_keys...)
|
||||||
|
if resp == nil || resp.NextPage == 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
page = resp.NextPage
|
||||||
|
}
|
||||||
|
if len(keys) == 0 {
|
||||||
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// enumerate ~/.ssh/*.pub files
|
// enumerate ~/.ssh/*.pub files
|
||||||
|
|||||||
@@ -14,11 +14,19 @@ import (
|
|||||||
func ListPullReviewComments(ctx *context.TeaContext, idx int64) ([]*gitea.PullReviewComment, error) {
|
func ListPullReviewComments(ctx *context.TeaContext, idx int64) ([]*gitea.PullReviewComment, error) {
|
||||||
c := ctx.Login.Client()
|
c := ctx.Login.Client()
|
||||||
|
|
||||||
reviews, _, err := c.ListPullReviews(ctx.Owner, ctx.Repo, idx, gitea.ListPullReviewsOptions{
|
var reviews []*gitea.PullReview
|
||||||
ListOptions: gitea.ListOptions{Page: -1},
|
for page := 1; ; {
|
||||||
})
|
page_reviews, resp, err := c.ListPullReviews(ctx.Owner, ctx.Repo, idx, gitea.ListPullReviewsOptions{
|
||||||
if err != nil {
|
ListOptions: gitea.ListOptions{Page: page, PageSize: 50},
|
||||||
return nil, err
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
reviews = append(reviews, page_reviews...)
|
||||||
|
if resp == nil || resp.NextPage == 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
page = resp.NextPage
|
||||||
}
|
}
|
||||||
|
|
||||||
var allComments []*gitea.PullReviewComment
|
var allComments []*gitea.PullReviewComment
|
||||||
|
|||||||
Reference in New Issue
Block a user