add more issue / pr creation params #331
|
@ -27,9 +27,10 @@ func PromptPassword(name string) (pass string, err error) {
|
|||
// promptRepoSlug interactively prompts for a Gitea repository or returns the current one
|
||||
func promptRepoSlug(defaultOwner, defaultRepo string) (owner, repo string, err error) {
|
||||
prompt := "Target repo:"
|
||||
defaultVal := ""
|
||||
required := true
|
||||
if len(defaultOwner) != 0 && len(defaultRepo) != 0 {
|
||||
prompt = fmt.Sprintf("Target repo [%s/%s]:", defaultOwner, defaultRepo)
|
||||
defaultVal = fmt.Sprintf("%s/%s", defaultOwner, defaultRepo)
|
||||
required = false
|
||||
}
|
||||
var repoSlug string
|
||||
|
@ -38,7 +39,10 @@ func promptRepoSlug(defaultOwner, defaultRepo string) (owner, repo string, err e
|
|||
repo = defaultRepo
|
||||
|
||||
err = survey.AskOne(
|
||||
&survey.Input{Message: prompt},
|
||||
&survey.Input{
|
||||
Message: prompt,
|
||||
Default: defaultVal,
|
||||
},
|
||||
&repoSlug,
|
||||
survey.WithValidator(func(input interface{}) error {
|
||||
if str, ok := input.(string); ok {
|
||||
|
|
|
@ -23,17 +23,14 @@ func CreatePull(login *config.Login, owner, repo string) error {
|
|||
}
|
||||
|
||||
// base
|
||||
baseBranch, err := task.GetDefaultPRBase(login, owner, repo)
|
||||
base, err = task.GetDefaultPRBase(login, owner, repo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
promptI := &survey.Input{Message: "Target branch [" + baseBranch + "]:"}
|
||||
promptI := &survey.Input{Message: "Target branch:", Default: base}
|
||||
if err := survey.AskOne(promptI, &base); err != nil {
|
||||
return err
|
||||
}
|
||||
if len(base) == 0 {
|
||||
base = baseBranch
|
||||
}
|
||||
|
||||
// head
|
||||
localRepo, err := git.RepoForWorkdir()
|
||||
|
@ -45,21 +42,14 @@ func CreatePull(login *config.Login, owner, repo string) error {
|
|||
if err == nil {
|
||||
promptOpts = nil
|
||||
}
|
||||
var headOwnerInput, headBranchInput string
|
||||
promptI = &survey.Input{Message: "Source repo owner [" + headOwner + "]:"}
|
||||
if err := survey.AskOne(promptI, &headOwnerInput); err != nil {
|
||||
promptI = &survey.Input{Message: "Source repo owner:", Default: headOwner}
|
||||
if err := survey.AskOne(promptI, &headOwner); err != nil {
|
||||
return err
|
||||
}
|
||||
if len(headOwnerInput) != 0 {
|
||||
headOwner = headOwnerInput
|
||||
}
|
||||
promptI = &survey.Input{Message: "Source branch [" + headBranch + "]:"}
|
||||
if err := survey.AskOne(promptI, &headBranchInput, promptOpts); err != nil {
|
||||
promptI = &survey.Input{Message: "Source branch:", Default: headBranch}
|
||||
if err := survey.AskOne(promptI, &headBranch, promptOpts); err != nil {
|
||||
return err
|
||||
}
|
||||
if len(headBranchInput) != 0 {
|
||||
headBranch = headBranchInput
|
||||
}
|
||||
|
||||
head = task.GetHeadSpec(headOwner, headBranch, owner)
|
||||
|
||||
|
@ -69,7 +59,7 @@ func CreatePull(login *config.Login, owner, repo string) error {
|
|||
if len(title) != 0 {
|
||||
promptOpts = nil
|
||||
}
|
||||
promptI = &survey.Input{Message: "PR title [" + title + "]:"}
|
||||
promptI = &survey.Input{Message: "PR title:", Default: title}
|
||||
if err := survey.AskOne(promptI, &title, promptOpts); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user