tenseleyflow/shithub / 7c9dd0d

Browse files

actions/trigger + scripts: gofumpt + drop unused placeholder + lint-unused bash 3.2 shim (S41b)

- gofumpt fixes across the trigger package + dispatch handler
- drop the stale 'startedAtNow' placeholder var in enqueue.go that
the lint-unused script flagged as a dead 'silence unused import'
shim (it was originally a hint for S41c+, but never used)
- scripts/lint-unused.sh: ${ALLOWED_FILES[@]:-} so an empty
array doesn't trip set -u under macOS bash 3.2
Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
7c9dd0d4789b042a805e99e30cca0daf62ffb0f8
Parents
b5d3edd
Tree
63bbcac

7 changed files

StatusFile+-
M cmd/shithubd/worker.go 1 1
M internal/actions/trigger/enqueue.go 0 8
M internal/actions/trigger/glob.go 3 3
M internal/actions/trigger/glob_test.go 2 2
M internal/actions/trigger/match.go 9 9
M internal/web/handlers/repo/actions_dispatch.go 2 1
M scripts/lint-unused.sh 4 2
cmd/shithubd/worker.gomodified
@@ -17,13 +17,13 @@ import (
17
 
17
 
18
 	"github.com/spf13/cobra"
18
 	"github.com/spf13/cobra"
19
 
19
 
20
+	"github.com/tenseleyFlow/shithub/internal/actions/trigger"
20
 	"github.com/tenseleyFlow/shithub/internal/auth/audit"
21
 	"github.com/tenseleyFlow/shithub/internal/auth/audit"
21
 	"github.com/tenseleyFlow/shithub/internal/auth/email"
22
 	"github.com/tenseleyFlow/shithub/internal/auth/email"
22
 	"github.com/tenseleyFlow/shithub/internal/auth/secretbox"
23
 	"github.com/tenseleyFlow/shithub/internal/auth/secretbox"
23
 	"github.com/tenseleyFlow/shithub/internal/infra/config"
24
 	"github.com/tenseleyFlow/shithub/internal/infra/config"
24
 	"github.com/tenseleyFlow/shithub/internal/infra/db"
25
 	"github.com/tenseleyFlow/shithub/internal/infra/db"
25
 	"github.com/tenseleyFlow/shithub/internal/infra/storage"
26
 	"github.com/tenseleyFlow/shithub/internal/infra/storage"
26
-	"github.com/tenseleyFlow/shithub/internal/actions/trigger"
27
 	"github.com/tenseleyFlow/shithub/internal/webhook"
27
 	"github.com/tenseleyFlow/shithub/internal/webhook"
28
 	"github.com/tenseleyFlow/shithub/internal/worker"
28
 	"github.com/tenseleyFlow/shithub/internal/worker"
29
 	"github.com/tenseleyFlow/shithub/internal/worker/jobs"
29
 	"github.com/tenseleyFlow/shithub/internal/worker/jobs"
internal/actions/trigger/enqueue.gomodified
@@ -8,7 +8,6 @@ import (
8
 	"errors"
8
 	"errors"
9
 	"fmt"
9
 	"fmt"
10
 	"log/slog"
10
 	"log/slog"
11
-	"time"
12
 
11
 
13
 	"github.com/jackc/pgx/v5"
12
 	"github.com/jackc/pgx/v5"
14
 	"github.com/jackc/pgx/v5/pgtype"
13
 	"github.com/jackc/pgx/v5/pgtype"
@@ -364,10 +363,3 @@ func marshalPermissions(p workflow.Permissions) ([]byte, error) {
364
 	}
363
 	}
365
 	return json.Marshal(out)
364
 	return json.Marshal(out)
366
 }
365
 }
367
-
368
-// startedAtNow is a small helper used by tests + future re-run callers
369
-// to set started_at on insert (S41c+ scenarios). Not currently used by
370
-// Enqueue — runs start in queued state.
371
-var _ = func() pgtype.Timestamptz {
372
-	return pgtype.Timestamptz{Time: time.Now(), Valid: true}
373
-}
internal/actions/trigger/glob.gomodified
@@ -24,10 +24,10 @@ var globCache sync.Map
24
 //   - `*`           matches any sequence of non-`/` characters.
24
 //   - `*`           matches any sequence of non-`/` characters.
25
 //   - `**`          matches any sequence including `/`.
25
 //   - `**`          matches any sequence including `/`.
26
 //   - `/**` at end  matches zero or more trailing segments
26
 //   - `/**` at end  matches zero or more trailing segments
27
-//                   (so `feature/**` matches both `feature` and
27
+//     (so `feature/**` matches both `feature` and
28
-//                   `feature/foo/bar`).
28
+//     `feature/foo/bar`).
29
 //   - `!pattern`    excludes. Evaluated in declaration order;
29
 //   - `!pattern`    excludes. Evaluated in declaration order;
30
-//                   last-match wins. (Mirrors minimatch.)
30
+//     last-match wins. (Mirrors minimatch.)
31
 //
31
 //
32
 // Empty pattern list returns true — "no filter" means "match all" per
32
 // Empty pattern list returns true — "no filter" means "match all" per
33
 // GHA convention.
33
 // GHA convention.
internal/actions/trigger/glob_test.gomodified
@@ -45,7 +45,7 @@ func TestGlobMatch_DoubleStar(t *testing.T) {
45
 		s       string
45
 		s       string
46
 		want    bool
46
 		want    bool
47
 	}{
47
 	}{
48
-		{"feature/**", "feature", true},          // zero trailing segments
48
+		{"feature/**", "feature", true}, // zero trailing segments
49
 		{"feature/**", "feature/foo", true},
49
 		{"feature/**", "feature/foo", true},
50
 		{"feature/**", "feature/foo/bar", true},
50
 		{"feature/**", "feature/foo/bar", true},
51
 		{"feature/**", "main", false},
51
 		{"feature/**", "main", false},
@@ -53,7 +53,7 @@ func TestGlobMatch_DoubleStar(t *testing.T) {
53
 		{"**/*.go", "pkg/sub/x.go", true},
53
 		{"**/*.go", "pkg/sub/x.go", true},
54
 		{"**/*.go", "pkg/sub/x.txt", false},
54
 		{"**/*.go", "pkg/sub/x.txt", false},
55
 		{"docs/**/*.md", "docs/internal/x.md", true},
55
 		{"docs/**/*.md", "docs/internal/x.md", true},
56
-		{"docs/**/*.md", "docs/x.md", true},      // ** matches zero segments
56
+		{"docs/**/*.md", "docs/x.md", true}, // ** matches zero segments
57
 		{"docs/**/*.md", "src/x.md", false},
57
 		{"docs/**/*.md", "src/x.md", false},
58
 		{"**", "literally/any/path", true},
58
 		{"**", "literally/any/path", true},
59
 	}
59
 	}
internal/actions/trigger/match.gomodified
@@ -12,17 +12,17 @@ import (
12
 // The four event kinds:
12
 // The four event kinds:
13
 //
13
 //
14
 //   - push              → on.push present, branch/tag classification
14
 //   - push              → on.push present, branch/tag classification
15
-//                         passes the appropriate sub-filter, paths
15
+//     passes the appropriate sub-filter, paths
16
-//                         filter (when set) hits at least one
16
+//     filter (when set) hits at least one
17
-//                         changed path
17
+//     changed path
18
 //   - pull_request      → on.pull_request present, action is in the
18
 //   - pull_request      → on.pull_request present, action is in the
19
-//                         configured types: list (default ["opened",
19
+//     configured types: list (default ["opened",
20
-//                         "synchronize", "reopened"]), base branch
20
+//     "synchronize", "reopened"]), base branch
21
-//                         passes branches: filter, paths filter hits
21
+//     passes branches: filter, paths filter hits
22
 //   - schedule          → on.schedule has any entry whose cron string
22
 //   - schedule          → on.schedule has any entry whose cron string
23
-//                         equals event.Cron (the sweep tells us which
23
+//     equals event.Cron (the sweep tells us which
24
-//                         cron fired; we just verify the workflow
24
+//     cron fired; we just verify the workflow
25
-//                         declared it)
25
+//     declared it)
26
 //   - workflow_dispatch → on.workflow_dispatch present
26
 //   - workflow_dispatch → on.workflow_dispatch present
27
 //
27
 //
28
 // Anything else returns false silently — strict-allowlist v1 posture.
28
 // Anything else returns false silently — strict-allowlist v1 posture.
internal/web/handlers/repo/actions_dispatch.gomodified
@@ -42,7 +42,8 @@ type dispatchRequest struct {
42
 const dispatchMaxBody = 64 * 1024
42
 const dispatchMaxBody = 64 * 1024
43
 
43
 
44
 // repoActionsDispatch implements
44
 // repoActionsDispatch implements
45
-//   POST /{owner}/{repo}/actions/workflows/{file}/dispatches
45
+//
46
+//	POST /{owner}/{repo}/actions/workflows/{file}/dispatches
46
 //
47
 //
47
 // 204 on success; the trigger pipeline runs synchronously here
48
 // 204 on success; the trigger pipeline runs synchronously here
48
 // because the workflow file is already known (no discovery needed),
49
 // because the workflow file is already known (no discovery needed),
scripts/lint-unused.shmodified
@@ -41,8 +41,10 @@ if [ -z "$matches" ]; then
41
   exit 0
41
   exit 0
42
 fi
42
 fi
43
 
43
 
44
-# Strip allowlisted files.
44
+# Strip allowlisted files. ${arr[@]:-} guards against bash 3.2's
45
-for allowed in "${ALLOWED_FILES[@]}"; do
45
+# unbound-empty-array behavior under set -u (macOS default shell).
46
+for allowed in "${ALLOWED_FILES[@]:-}"; do
47
+  [ -z "$allowed" ] && continue
46
   matches=$(echo "$matches" | grep -v "^${allowed}:" || true)
48
   matches=$(echo "$matches" | grep -v "^${allowed}:" || true)
47
 done
49
 done
48
 
50