Add Repo Create subcomand & enhancements #173

Merged
6543 merged 20 commits from 6543/tea:repos-create into master 2020-09-23 19:50:02 +00:00
Showing only changes of commit 7873abe197 - Show all commits

View File

@ -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",
Outdated
Review

lets use owner / -O everywhere, and avoid two terms for the same concept

lets use `owner` / `-O` everywhere, and avoid two terms for the same concept
Outdated
Review

And why are there two flags org and user? Can't they be merged into --owner?

And why are there two flags `org` and `user`? Can't they be merged into `--owner`?
Outdated
Review

It will add a request ...
but It's user convinient So why not ...

It will add a request ... but It's user convinient So why not ...
Outdated
Review

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

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
Review

changed :)

changed :)
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

TODO: is usually better detected by IDEs

`TODO:` is usually better detected by IDEs
Outdated
Review

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.

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.
Outdated
Review

If we use login, _, _ := initCommand() outside of a repo we will get this:

Error: repository does not exist

If we use `login, _, _ := initCommand()` outside of a repo we will get this: Error: repository does not exist
Outdated
Review

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
Outdated
Review

... 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 {