move git auth prompts to interact module (#276)

move password prompt to interact module

closes #231

allow up to 3 ssh key password attempts

rename param

Co-authored-by: Norwin Roosen <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/276
Reviewed-by: 6543 <6543@obermui.de>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-Authored-By: Norwin <noerw@noreply.gitea.io>
Co-Committed-By: Norwin <noerw@noreply.gitea.io>
This commit is contained in:
Norwin
2020-12-08 09:21:05 +08:00
committed by 6543
parent 9a3b54b9a3
commit d0e05e8be2
4 changed files with 38 additions and 22 deletions

View File

@ -10,7 +10,7 @@ import (
"code.gitea.io/sdk/gitea"
"code.gitea.io/tea/modules/config"
local_git "code.gitea.io/tea/modules/git"
"code.gitea.io/tea/modules/interact"
"github.com/go-git/go-git/v5"
)
@ -60,7 +60,7 @@ func PullCheckout(login *config.Login, repoOwner, repoName string, index int64)
if err != nil {
return err
}
auth, err := local_git.GetAuthForURL(url, login.Token, login.SSHKey)
auth, err := local_git.GetAuthForURL(url, login.Token, login.SSHKey, interact.PromptPassword)
if err != nil {
return err
}

View File

@ -7,10 +7,11 @@ package task
import (
"fmt"
"code.gitea.io/sdk/gitea"
"code.gitea.io/tea/modules/config"
local_git "code.gitea.io/tea/modules/git"
"code.gitea.io/tea/modules/interact"
"code.gitea.io/sdk/gitea"
git_config "github.com/go-git/go-git/v5/config"
)
@ -78,7 +79,7 @@ call me again with the --ignore-sha flag`, pr.Head.Ref)
if err != nil {
return err
}
auth, err := local_git.GetAuthForURL(url, login.Token, login.SSHKey)
auth, err := local_git.GetAuthForURL(url, login.Token, login.SSHKey, interact.PromptPassword)
if err != nil {
return err
}