Add authenticator to all Git calls (makes it possible to have private repos)

This commit is contained in:
Mustafa Gezen 2022-03-25 17:39:50 +01:00
parent 102ff0427a
commit 70c4c22665
2 changed files with 6 additions and 1 deletions

View File

@ -82,6 +82,7 @@ func (g *GitMode) RetrieveSource(pd *data.ProcessData) (*data.ModeData, error) {
} }
err = remote.Fetch(&git.FetchOptions{ err = remote.Fetch(&git.FetchOptions{
Auth: pd.Authenticator,
RefSpecs: []config.RefSpec{refspec}, RefSpecs: []config.RefSpec{refspec},
Tags: git.AllTags, Tags: git.AllTags,
Force: true, Force: true,
@ -120,7 +121,9 @@ func (g *GitMode) RetrieveSource(pd *data.ProcessData) (*data.ModeData, error) {
} }
_ = tagIter.ForEach(tagAdd) _ = tagIter.ForEach(tagAdd)
list, err := remote.List(&git.ListOptions{}) list, err := remote.List(&git.ListOptions{
Auth: pd.Authenticator,
})
if err != nil { if err != nil {
return nil, fmt.Errorf("could not list upstream: %v", err) return nil, fmt.Errorf("could not list upstream: %v", err)
} }
@ -180,6 +183,7 @@ func (g *GitMode) WriteSource(pd *data.ProcessData, md *data.ModeData) error {
} }
pd.Log.Printf("checking out upstream refspec %s", refspec) pd.Log.Printf("checking out upstream refspec %s", refspec)
err = remote.Fetch(&git.FetchOptions{ err = remote.Fetch(&git.FetchOptions{
Auth: pd.Authenticator,
RemoteName: "upstream", RemoteName: "upstream",
RefSpecs: []config.RefSpec{refspec}, RefSpecs: []config.RefSpec{refspec},
Tags: git.AllTags, Tags: git.AllTags,

View File

@ -128,6 +128,7 @@ func executePatchesRpm(pd *data.ProcessData, md *data.ModeData) error {
} }
fetchOptions := &git.FetchOptions{ fetchOptions := &git.FetchOptions{
Auth: pd.Authenticator,
RemoteName: "origin", RemoteName: "origin",
RefSpecs: []config.RefSpec{refspec}, RefSpecs: []config.RefSpec{refspec},
} }