mirror of
https://gitea.com/gitea/tea.git
synced 2025-09-03 18:38:29 +02:00
Fix tea login add with ssh public key bug (#789)
Fix #705 Reviewed-on: https://gitea.com/gitea/tea/pulls/789 Reviewed-by: techknowlogick <techknowlogick@noreply.gitea.com>
This commit is contained in:
@ -168,7 +168,12 @@ func CreateLogin() error {
|
|||||||
printTitleAndContent("SSH Key/Certificate Path (leave empty for auto-discovery in ~/.ssh and ssh-agent):", sshKey)
|
printTitleAndContent("SSH Key/Certificate Path (leave empty for auto-discovery in ~/.ssh and ssh-agent):", sshKey)
|
||||||
|
|
||||||
if sshKey == "" {
|
if sshKey == "" {
|
||||||
sshKey, err = promptSelect("Select ssh-key: ", task.ListSSHPubkey(), "", "", "")
|
pubKeys := task.ListSSHPubkey()
|
||||||
|
if len(pubKeys) == 0 {
|
||||||
|
fmt.Println("No SSH keys found in ~/.ssh or ssh-agent")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
sshKey, err = promptSelect("Select ssh-key: ", pubKeys, "", "", "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ package interact
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -125,7 +126,9 @@ func promptSelect(prompt string, options []string, customVal, noneVal, defaultVa
|
|||||||
if defaultVal == "" && noneVal != "" {
|
if defaultVal == "" && noneVal != "" {
|
||||||
defaultVal = noneVal
|
defaultVal = noneVal
|
||||||
}
|
}
|
||||||
|
if len(options) > 0 && !slices.Contains(options, defaultVal) {
|
||||||
|
defaultVal = options[0]
|
||||||
|
}
|
||||||
selection = defaultVal
|
selection = defaultVal
|
||||||
if err := huh.NewSelect[string]().
|
if err := huh.NewSelect[string]().
|
||||||
Title(prompt).
|
Title(prompt).
|
||||||
|
Reference in New Issue
Block a user