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 (
1717
 
1818
 	"github.com/spf13/cobra"
1919
 
20
+	"github.com/tenseleyFlow/shithub/internal/actions/trigger"
2021
 	"github.com/tenseleyFlow/shithub/internal/auth/audit"
2122
 	"github.com/tenseleyFlow/shithub/internal/auth/email"
2223
 	"github.com/tenseleyFlow/shithub/internal/auth/secretbox"
2324
 	"github.com/tenseleyFlow/shithub/internal/infra/config"
2425
 	"github.com/tenseleyFlow/shithub/internal/infra/db"
2526
 	"github.com/tenseleyFlow/shithub/internal/infra/storage"
26
-	"github.com/tenseleyFlow/shithub/internal/actions/trigger"
2727
 	"github.com/tenseleyFlow/shithub/internal/webhook"
2828
 	"github.com/tenseleyFlow/shithub/internal/worker"
2929
 	"github.com/tenseleyFlow/shithub/internal/worker/jobs"
internal/actions/trigger/enqueue.gomodified
@@ -8,7 +8,6 @@ import (
88
 	"errors"
99
 	"fmt"
1010
 	"log/slog"
11
-	"time"
1211
 
1312
 	"github.com/jackc/pgx/v5"
1413
 	"github.com/jackc/pgx/v5/pgtype"
@@ -364,10 +363,3 @@ func marshalPermissions(p workflow.Permissions) ([]byte, error) {
364363
 	}
365364
 	return json.Marshal(out)
366365
 }
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
2424
 //   - `*`           matches any sequence of non-`/` characters.
2525
 //   - `**`          matches any sequence including `/`.
2626
 //   - `/**` at end  matches zero or more trailing segments
27
-//                   (so `feature/**` matches both `feature` and
28
-//                   `feature/foo/bar`).
27
+//     (so `feature/**` matches both `feature` and
28
+//     `feature/foo/bar`).
2929
 //   - `!pattern`    excludes. Evaluated in declaration order;
30
-//                   last-match wins. (Mirrors minimatch.)
30
+//     last-match wins. (Mirrors minimatch.)
3131
 //
3232
 // Empty pattern list returns true — "no filter" means "match all" per
3333
 // GHA convention.
internal/actions/trigger/glob_test.gomodified
@@ -45,7 +45,7 @@ func TestGlobMatch_DoubleStar(t *testing.T) {
4545
 		s       string
4646
 		want    bool
4747
 	}{
48
-		{"feature/**", "feature", true},          // zero trailing segments
48
+		{"feature/**", "feature", true}, // zero trailing segments
4949
 		{"feature/**", "feature/foo", true},
5050
 		{"feature/**", "feature/foo/bar", true},
5151
 		{"feature/**", "main", false},
@@ -53,7 +53,7 @@ func TestGlobMatch_DoubleStar(t *testing.T) {
5353
 		{"**/*.go", "pkg/sub/x.go", true},
5454
 		{"**/*.go", "pkg/sub/x.txt", false},
5555
 		{"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
5757
 		{"docs/**/*.md", "src/x.md", false},
5858
 		{"**", "literally/any/path", true},
5959
 	}
internal/actions/trigger/match.gomodified
@@ -12,17 +12,17 @@ import (
1212
 // The four event kinds:
1313
 //
1414
 //   - push              → on.push present, branch/tag classification
15
-//                         passes the appropriate sub-filter, paths
16
-//                         filter (when set) hits at least one
17
-//                         changed path
15
+//     passes the appropriate sub-filter, paths
16
+//     filter (when set) hits at least one
17
+//     changed path
1818
 //   - pull_request      → on.pull_request present, action is in the
19
-//                         configured types: list (default ["opened",
20
-//                         "synchronize", "reopened"]), base branch
21
-//                         passes branches: filter, paths filter hits
19
+//     configured types: list (default ["opened",
20
+//     "synchronize", "reopened"]), base branch
21
+//     passes branches: filter, paths filter hits
2222
 //   - schedule          → on.schedule has any entry whose cron string
23
-//                         equals event.Cron (the sweep tells us which
24
-//                         cron fired; we just verify the workflow
25
-//                         declared it)
23
+//     equals event.Cron (the sweep tells us which
24
+//     cron fired; we just verify the workflow
25
+//     declared it)
2626
 //   - workflow_dispatch → on.workflow_dispatch present
2727
 //
2828
 // Anything else returns false silently — strict-allowlist v1 posture.
internal/web/handlers/repo/actions_dispatch.gomodified
@@ -42,7 +42,8 @@ type dispatchRequest struct {
4242
 const dispatchMaxBody = 64 * 1024
4343
 
4444
 // repoActionsDispatch implements
45
-//   POST /{owner}/{repo}/actions/workflows/{file}/dispatches
45
+//
46
+//	POST /{owner}/{repo}/actions/workflows/{file}/dispatches
4647
 //
4748
 // 204 on success; the trigger pipeline runs synchronously here
4849
 // because the workflow file is already known (no discovery needed),
scripts/lint-unused.shmodified
@@ -41,8 +41,10 @@ if [ -z "$matches" ]; then
4141
   exit 0
4242
 fi
4343
 
44
-# Strip allowlisted files.
45
-for allowed in "${ALLOWED_FILES[@]}"; do
44
+# Strip allowlisted files. ${arr[@]:-} guards against bash 3.2's
45
+# unbound-empty-array behavior under set -u (macOS default shell).
46
+for allowed in "${ALLOWED_FILES[@]:-}"; do
47
+  [ -z "$allowed" ] && continue
4648
   matches=$(echo "$matches" | grep -v "^${allowed}:" || true)
4749
 done
4850