44 "encoding/json"
55 "errors"
66 "fmt"
7+ "github.com/go-git/go-git/v5/plumbing/transport"
78 "io/ioutil"
89 "os"
910 "strings"
@@ -26,6 +27,7 @@ type GitWatcher struct {
2627 syncing uint32
2728
2829 repository * git.Repository
30+ auth transport.AuthMethod
2931
3032 ticker * time.Ticker
3133 stop chan bool
@@ -442,19 +444,20 @@ func (w *GitWatcher) updateRepo() error {
442444
443445 case "http_token" :
444446 opts .Auth = & http.BasicAuth {
445- Username : "token" ,
447+ Username : w . config . HTTPUsername ,
446448 Password : w .config .HTTPToken ,
447449 }
448450
449451 case "http_user_pass" :
450452 opts .Auth = & http.BasicAuth {
451- Username : w .config .HTTPPassword ,
452- Password : w .config .HTTPToken ,
453+ Username : w .config .HTTPUsername ,
454+ Password : w .config .HTTPPassword ,
453455 }
454456
455457 default :
456458
457459 }
460+ w .auth = opts .Auth
458461
459462 r , err := git .PlainClone (w .config .TempDir , false , opts )
460463 if err != nil && err == git .ErrRepositoryAlreadyExists {
@@ -472,9 +475,11 @@ func (w *GitWatcher) updateRepo() error {
472475 }
473476
474477 // Update the repository
475- err = wt .Pull (& git.PullOptions {})
478+ err = wt .Pull (& git.PullOptions {
479+ Auth : w .auth ,
480+ })
476481 if err != nil && err != git .NoErrAlreadyUpToDate {
477- return fmt .Errorf ("checkout of repo '%s': %s" , w .config .RepoBranch , err )
482+ return fmt .Errorf ("checkout of repo '%s': %s" , w .config .RepoURL , err )
478483 }
479484 return nil
480485}
0 commit comments