diff --git a/server/backend/sqlite/sqlite.go b/server/backend/sqlite/sqlite.go index d38ae26b8d0e801f2771a5346329dd10658bdbc9..91527e3fcc0a82b8b35e8f1cba9eab55477cd8bb 100644 --- a/server/backend/sqlite/sqlite.go +++ b/server/backend/sqlite/sqlite.go @@ -603,9 +603,6 @@ func (d *SqliteBackend) RemoveCollaborator(repo string, username string) error { } func (d *SqliteBackend) initRepo(repo string) error { - if os.Getenv("SOFT_SERVE_TEST_NO_HOOKS") == "1" { - return nil - } return hooks.GenerateHooks(d.ctx, d.cfg, repo) } diff --git a/server/hooks/hooks.go b/server/hooks/hooks.go index 08968ed1056f46c7313279025a3c134633456056..adf185d3c8efdb43e7fcb4ce326b5e1339d9675f 100644 --- a/server/hooks/hooks.go +++ b/server/hooks/hooks.go @@ -3,6 +3,7 @@ package hooks import ( "bytes" "context" + "flag" "fmt" "os" "path/filepath" @@ -28,8 +29,12 @@ const ( // - post-update // // This function should be called by the backend when a repository is created. -// TODO: support context -func GenerateHooks(ctx context.Context, cfg *config.Config, repo string) error { +// TODO: support context. +func GenerateHooks(_ context.Context, cfg *config.Config, repo string) error { + if flag.Lookup("test.v") != nil { + log.WithPrefix("backend.hooks").Warn("refusing to set up hooks when in test") + return nil + } repo = utils.SanitizeRepo(repo) + ".git" hooksPath := filepath.Join(cfg.DataPath, "repos", repo, "hooks") if err := os.MkdirAll(hooksPath, os.ModePerm); err != nil { diff --git a/testscript/script_test.go b/testscript/script_test.go index b31f4438bdfb5a11bd72251e310a41f64b139abd..468cb4f82ca330ac9914c176e849860cfbc6c98f 100644 --- a/testscript/script_test.go +++ b/testscript/script_test.go @@ -28,8 +28,6 @@ func TestScript(t *testing.T) { flag.Parse() var lock sync.Mutex - t.Setenv("SOFT_SERVE_TEST_NO_HOOKS", "1") - mkkey := func(name string) (string, *keygen.SSHKeyPair) { path := filepath.Join(t.TempDir(), name) pair, err := keygen.New(path, keygen.WithKeyType(keygen.Ed25519), keygen.WithWrite())