diff --git a/git/gitlab/gitlab.go b/git/gitlab/gitlab.go index 0a5997c7..51e664d5 100644 --- a/git/gitlab/gitlab.go +++ b/git/gitlab/gitlab.go @@ -401,7 +401,8 @@ func (g *Gitlab) compareFiles() ([]manager.CommitFile, error) { if err != nil { // if the tree is not found it's probably just because there are no files at all currently... // So we have to apply all pending ones. - if strings.Contains(err.Error(), "Tree Not Found") { + if errors.Is(err, gitlab.ErrNotFound) { + g.log.Info("ListTree got 404; most likely no files found in repository, applying all pending files") for name, content := range g.ops.TemplateFiles { if content != manager.DeletionMagicString { diff --git a/git/gitlab/gitlab_test.go b/git/gitlab/gitlab_test.go index cfab6be0..bda121de 100644 --- a/git/gitlab/gitlab_test.go +++ b/git/gitlab/gitlab_test.go @@ -435,7 +435,7 @@ func testGetCommitServer(t *testing.T, files []string) *httptest.Server { mux.HandleFunc("/api/v4/projects/3/repository/tree", func(res http.ResponseWriter, req *http.Request) { if len(files) == 0 { - _, _ = res.Write([]byte(`[]`)) + res.WriteHeader(http.StatusNotFound) return }