fix (git): fix issue while trying to connect to an empty repo

This commit is contained in:
Mickael KERJEAN 2019-01-13 10:35:04 +11:00
parent 595eff4015
commit d0f1e59782
2 changed files with 5 additions and 2 deletions

View file

@ -277,7 +277,6 @@ func (this *Configuration) Debug() *FormElement {
}
func (this *Configuration) Initialise() {
Log.Stdout("CONFIG INIT ADMIN PASSWORD '%s'", os.Getenv("ADMIN_PASSWORD"))
if env := os.Getenv("ADMIN_PASSWORD"); env != "" {
this.Get("auth.admin").Set(env)
}

View file

@ -328,13 +328,17 @@ func (g *GitLib) open(params *GitParams, path string) (*git.Repository, error) {
if err != nil {
return nil, err
}
return git.PlainClone(path, false, &git.CloneOptions{
g, err := git.PlainClone(path, false, &git.CloneOptions{
URL: g.params.repo,
Depth: 1,
ReferenceName: plumbing.ReferenceName(fmt.Sprintf("refs/heads/%s", g.params.branch)),
SingleBranch: true,
Auth: auth,
})
if err == transport.ErrEmptyRemoteRepository {
return g, nil
}
return g, err
}
return git.PlainOpen(g.params.basePath)
}