1
0
mirror of https://github.com/mgechev/revive.git synced 2025-11-23 22:04:49 +02:00

package-directory-mismatch: ignore mismatch in root directory (#1548)

This commit is contained in:
Godsgift Uloamaka Ebite
2025-10-24 17:26:03 +01:00
committed by GitHub
parent 91147bf0b5
commit 26d803fc96
7 changed files with 64 additions and 1 deletions

View File

@@ -412,3 +412,27 @@ func TestExportedType(t *testing.T) {
}
}
}
// mkdirTempDotGit adds a temporary .git directory to the given root directory in testdata.
// We can't commit .git directly because of the Git restrictions.
func mkdirTempDotGit(t *testing.T, root string) {
t.Helper()
baseDir := filepath.Join("..", "testdata", root)
dir, err := filepath.Abs(baseDir)
if err != nil {
t.Fatalf("Failed to resolve abs path: %v", err)
}
gitDir := filepath.Join(dir, ".git")
if err := os.MkdirAll(gitDir, 0o755); err != nil {
t.Fatalf("Failed to create .git directory: %v", err)
}
t.Cleanup(func() {
err = os.RemoveAll(gitDir)
if err != nil {
t.Logf("Failed to remove %v: %v", gitDir, err)
}
})
}