mirror of
https://github.com/MichaelMure/git-bug.git
synced 2024-12-15 10:12:06 +03:00
Merge pull request #262 from MichaelMure/bridge
bridge: trim inputs during bridge configuration
This commit is contained in:
commit
26a6269241
@ -101,7 +101,7 @@ func (g *Github) Configure(repo repository.RepoCommon, params core.BridgeParams)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("reading from stdin: %v", err)
|
return nil, fmt.Errorf("reading from stdin: %v", err)
|
||||||
}
|
}
|
||||||
token = strings.TrimSuffix(token, "\n")
|
token = strings.TrimSpace(token)
|
||||||
} else if params.TokenId != "" {
|
} else if params.TokenId != "" {
|
||||||
tokenId = entity.Id(params.TokenId)
|
tokenId = entity.Id(params.TokenId)
|
||||||
} else {
|
} else {
|
||||||
@ -268,7 +268,7 @@ func promptTokenOptions(repo repository.RepoCommon, owner, project string) (*cor
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
line = strings.TrimRight(line, "\n")
|
line = strings.TrimSpace(line)
|
||||||
|
|
||||||
index, err := strconv.Atoi(line)
|
index, err := strconv.Atoi(line)
|
||||||
if err != nil || index < 1 || index > len(tokens)+2 {
|
if err != nil || index < 1 || index > len(tokens)+2 {
|
||||||
@ -320,7 +320,7 @@ func promptToken() (string, error) {
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
token := strings.TrimRight(line, "\n")
|
token := strings.TrimSpace(line)
|
||||||
if re.MatchString(token) {
|
if re.MatchString(token) {
|
||||||
return token, nil
|
return token, nil
|
||||||
}
|
}
|
||||||
@ -409,7 +409,7 @@ func promptUsername() (string, error) {
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
line = strings.TrimRight(line, "\n")
|
line = strings.TrimSpace(line)
|
||||||
|
|
||||||
ok, err := validateUsername(line)
|
ok, err := validateUsername(line)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -442,7 +442,7 @@ func promptURL(remotes map[string]string) (string, string, error) {
|
|||||||
return "", "", err
|
return "", "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
line = strings.TrimRight(line, "\n")
|
line = strings.TrimSpace(line)
|
||||||
|
|
||||||
index, err := strconv.Atoi(line)
|
index, err := strconv.Atoi(line)
|
||||||
if err != nil || index < 0 || index > len(validRemotes) {
|
if err != nil || index < 0 || index > len(validRemotes) {
|
||||||
@ -470,7 +470,7 @@ func promptURL(remotes map[string]string) (string, string, error) {
|
|||||||
return "", "", err
|
return "", "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
line = strings.TrimRight(line, "\n")
|
line = strings.TrimSpace(line)
|
||||||
if line == "" {
|
if line == "" {
|
||||||
fmt.Println("URL is empty")
|
fmt.Println("URL is empty")
|
||||||
continue
|
continue
|
||||||
@ -643,7 +643,7 @@ func promptProjectVisibility() (bool, error) {
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
line = strings.TrimRight(line, "\n")
|
line = strings.TrimSpace(line)
|
||||||
|
|
||||||
index, err := strconv.Atoi(line)
|
index, err := strconv.Atoi(line)
|
||||||
if err != nil || (index != 1 && index != 2) {
|
if err != nil || (index != 1 && index != 2) {
|
||||||
|
@ -67,7 +67,7 @@ func (g *Gitlab) Configure(repo repository.RepoCommon, params core.BridgeParams)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("reading from stdin: %v", err)
|
return nil, fmt.Errorf("reading from stdin: %v", err)
|
||||||
}
|
}
|
||||||
token = strings.TrimSuffix(token, "\n")
|
token = strings.TrimSpace(token)
|
||||||
} else if params.TokenId != "" {
|
} else if params.TokenId != "" {
|
||||||
tokenId = entity.Id(params.TokenId)
|
tokenId = entity.Id(params.TokenId)
|
||||||
} else {
|
} else {
|
||||||
@ -154,7 +154,7 @@ func promptTokenOptions(repo repository.RepoCommon) (*core.Token, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
line = strings.TrimRight(line, "\n")
|
line = strings.TrimSpace(line)
|
||||||
index, err := strconv.Atoi(line)
|
index, err := strconv.Atoi(line)
|
||||||
if err != nil || index < 1 || index > len(tokens)+1 {
|
if err != nil || index < 1 || index > len(tokens)+1 {
|
||||||
fmt.Println("invalid input")
|
fmt.Println("invalid input")
|
||||||
@ -196,7 +196,7 @@ func promptToken() (string, error) {
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
token := strings.TrimRight(line, "\n")
|
token := strings.TrimSpace(line)
|
||||||
if re.MatchString(token) {
|
if re.MatchString(token) {
|
||||||
return token, nil
|
return token, nil
|
||||||
}
|
}
|
||||||
@ -224,7 +224,7 @@ func promptURL(remotes map[string]string) (string, error) {
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
line = strings.TrimRight(line, "\n")
|
line = strings.TrimSpace(line)
|
||||||
|
|
||||||
index, err := strconv.Atoi(line)
|
index, err := strconv.Atoi(line)
|
||||||
if err != nil || index < 0 || index > len(validRemotes) {
|
if err != nil || index < 0 || index > len(validRemotes) {
|
||||||
@ -250,7 +250,7 @@ func promptURL(remotes map[string]string) (string, error) {
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := strings.TrimRight(line, "\n")
|
url := strings.TrimSpace(line)
|
||||||
if line == "" {
|
if line == "" {
|
||||||
fmt.Println("URL is empty")
|
fmt.Println("URL is empty")
|
||||||
continue
|
continue
|
||||||
|
@ -82,7 +82,7 @@ func promptTarget() (string, error) {
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
line = strings.TrimRight(line, "\n")
|
line = strings.TrimSpace(line)
|
||||||
|
|
||||||
index, err := strconv.Atoi(line)
|
index, err := strconv.Atoi(line)
|
||||||
if err != nil || index <= 0 || index > len(targets) {
|
if err != nil || index <= 0 || index > len(targets) {
|
||||||
@ -109,7 +109,7 @@ func promptName(repo repository.RepoCommon) (string, error) {
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
line = strings.TrimRight(line, "\n")
|
line = strings.TrimSpace(line)
|
||||||
|
|
||||||
name := line
|
name := line
|
||||||
if defaultExist && name == "" {
|
if defaultExist && name == "" {
|
||||||
|
Loading…
Reference in New Issue
Block a user