Change summary
server/backend/sqlite/sqlite.go | 3 ---
server/hooks/hooks.go | 9 +++++++--
testscript/script_test.go | 2 --
3 files changed, 7 insertions(+), 7 deletions(-)
Detailed changes
@@ -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)
}
@@ -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 {
@@ -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())