More Options To Specify Repo (#178)
use active user as owner by default Fix #163 Part1 Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://gitea.com/gitea/tea/pulls/178 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Reviewed-by: mrsdizzie <info@mrsdizzie.com>
This commit is contained in:
21
cmd/flags.go
21
cmd/flags.go
@@ -7,6 +7,8 @@ package cmd
|
||||
import (
|
||||
"log"
|
||||
|
||||
"code.gitea.io/tea/modules/utils"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
@@ -81,16 +83,31 @@ var AllDefaultFlags = append([]cli.Flag{
|
||||
|
||||
// initCommand returns repository and *Login based on flags
|
||||
func initCommand() (*Login, string, string) {
|
||||
var (
|
||||
login *Login
|
||||
repoPath string
|
||||
)
|
||||
err := loadConfig(yamlConfigPath)
|
||||
if err != nil {
|
||||
log.Fatal("load config file failed ", yamlConfigPath)
|
||||
}
|
||||
|
||||
login, repoPath, err := curGitRepoPath(repoValue)
|
||||
if login, err = getActiveLogin(); err != nil {
|
||||
log.Fatal(err.Error())
|
||||
}
|
||||
|
||||
exist, err := utils.PathExists(repoValue)
|
||||
if err != nil {
|
||||
log.Fatal(err.Error())
|
||||
}
|
||||
|
||||
if exist || len(repoValue) == 0 {
|
||||
login, repoPath, err = curGitRepoPath(repoValue)
|
||||
if err != nil {
|
||||
log.Fatal(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
if loginValue != "" {
|
||||
login = getLoginByName(loginValue)
|
||||
if login == nil {
|
||||
@@ -98,7 +115,7 @@ func initCommand() (*Login, string, string) {
|
||||
}
|
||||
}
|
||||
|
||||
owner, repo := splitRepo(repoPath)
|
||||
owner, repo := getOwnerAndRepo(repoPath, login.User)
|
||||
return login, owner, repo
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user