From ddcbd8d022af0451ff87734fb443b27f98a490dd Mon Sep 17 00:00:00 2001 From: Sebastien Devaux Date: Tue, 27 Aug 2019 21:35:04 +0200 Subject: [PATCH] issue 178: adding required changes to InitGitRepo and CleanupTestRepos --- repository/git.go | 2 +- repository/git_testing.go | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/repository/git.go b/repository/git.go index c03cf979bd3952d0dd741c1bfd7746dafda50ffe..d9a92c825bb4e11f7454d8f69812ab87e2bbcc97 100644 --- a/repository/git.go +++ b/repository/git.go @@ -115,7 +115,7 @@ func NewGitRepo(path string, witnesser Witnesser) (*GitRepo, error) { // InitGitRepo create a new empty git repo at the given path func InitGitRepo(path string) (*GitRepo, error) { - repo := &GitRepo{Path: path} + repo := &GitRepo{Path: path+"/.git"} err := repo.createClocks() if err != nil { return nil, err diff --git a/repository/git_testing.go b/repository/git_testing.go index dd597a8e4886ab17b4c5d437cccbfa7ddd4ce5c6..b844fbbe883fdfc722516d3904f763648499ce9b 100644 --- a/repository/git_testing.go +++ b/repository/git_testing.go @@ -1,6 +1,7 @@ package repository import ( + "strings" "io/ioutil" "log" "os" @@ -44,6 +45,17 @@ func CleanupTestRepos(t testing.TB, repos ...Repo) { var firstErr error for _, repo := range repos { path := repo.GetPath() + if (strings.HasSuffix(path,"/.git")) { + // non bare repository, remove complete repos not + // only git meta data. + path=strings.TrimSuffix(path,"/.git"); + // Testing non bare repo should also check path is + // only .git (i.e. ./.git), but doing so, we should + // try to remove the current directory and hav some + // trouble. In the present case, this case should not + // occure. + // TODO consider warning or error when path == ".git" + } // fmt.Println("Cleaning repo:", path) err := os.RemoveAll(path) if err != nil {