Remove Interact Dependency Of Task Module (#280)

remove interact dependency in task module

accept nil callback

format code

Reviewed-on: https://gitea.com/gitea/tea/pulls/280
Reviewed-by: Norwin <noerw@noreply.gitea.io>
Reviewed-by: Andrew Thornton <art27@cantab.net>
Co-Authored-By: 6543 <6543@obermui.de>
Co-Committed-By: 6543 <6543@obermui.de>
This commit is contained in:
6543
2020-12-08 19:25:21 +08:00
committed by Andrew Thornton
parent 5cb3e1ded5
commit c98441b13c
5 changed files with 15 additions and 14 deletions

View File

@ -10,12 +10,12 @@ 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"
)
// PullCheckout checkout current workdir to the head branch of specified pull request
func PullCheckout(login *config.Login, repoOwner, repoName string, index int64) error {
func PullCheckout(login *config.Login, repoOwner, repoName string, index int64, callback func(string) (string, error)) error {
client := login.Client()
localRepo, err := local_git.RepoForWorkdir()
@ -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, interact.PromptPassword)
auth, err := local_git.GetAuthForURL(url, login.Token, login.SSHKey, callback)
if err != nil {
return err
}