Add Repo Create subcomand & enhancements #173
34
cmd/repos.go
34
cmd/repos.go
|
@ -7,6 +7,7 @@ package cmd
|
|||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/tea/modules/utils"
|
||||
|
@ -43,13 +44,8 @@ var CmdReposList = cli.Command{
|
|||
Usage: "Filter by mode: fork, mirror, source",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "user",
|
||||
Aliases: []string{"u"},
|
||||
Required: false,
|
||||
Usage: "Filter by owner",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "org",
|
||||
Name: "owner",
|
||||
|
||||
Aliases: []string{"O"},
|
||||
Required: false,
|
||||
Usage: "Filter by owner",
|
||||
},
|
||||
|
@ -146,18 +142,22 @@ func runReposList(ctx *cli.Context) error {
|
|||
client := login.Client()
|
||||
|
||||
var ownerID int64
|
||||
if ctx.IsSet("user") {
|
||||
owner, _, err := client.GetUserInfo(ctx.String("user"))
|
||||
if ctx.IsSet("owner") {
|
||||
6543 marked this conversation as resolved
Outdated
zeripath
commented
`TODO:` is usually better detected by IDEs
noerw
commented
By using This came up in #189 as well, where I wrote a workaround. By using `initCommandLoginOnly()`, the login is not read from the current repo!
This came up in #189 as well, where I wrote a workaround.
But we need a proper solution for cases where the command is meaningful when executed outside of a repo, but we still want it to consider repo context where available.
6543
commented
If we use Error: repository does not exist If we use `login, _, _ := initCommand()` outside of a repo we will get this:
Error: repository does not exist
6543
commented
So yes we somehow have to unify both commands but in a way it will work for all commands So yes we somehow have to unify both commands but in a way it will work for all commands
6543
commented
... witch is no mouch for this pull ... witch is no mouch for this pull
|
||||
// test if owner is a organisation
|
||||
org, resp, err := client.GetOrg(ctx.String("owner"))
|
||||
if err != nil {
|
||||
return err
|
||||
if resp == nil || resp.StatusCode != http.StatusNotFound {
|
||||
return err
|
||||
}
|
||||
// if owner is no org, its a user
|
||||
user, _, err := client.GetUserInfo(ctx.String("owner"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ownerID = user.ID
|
||||
} else {
|
||||
ownerID = org.ID
|
||||
}
|
||||
ownerID = owner.ID
|
||||
} else if ctx.IsSet("org") {
|
||||
org, _, err := client.GetOrg(ctx.String("org"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ownerID = org.ID
|
||||
} else {
|
||||
me, _, err := client.GetMyUserInfo()
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue
Block a user
lets use
owner
/-O
everywhere, and avoid two terms for the same conceptAnd why are there two flags
org
anduser
? Can't they be merged into--owner
?It will add a request ...
but It's user convinient So why not ...
Hm, I consider two flags for the same field is more confusing than convenient, but idk.
Let's leave it as is, but please change the description to say "Filter by user" then
changed :)