Skip to content

Commit 64a6c14

Browse files
committed
feat(stovepipe): add commit ingestion hooks and push filtering
Introduce CommitEvent, CommitIngester/CommitEventHandler, a no-op logging handler stub, and repo/branch watch filtering for downstream ingestion.
1 parent 480d635 commit 64a6c14

4 files changed

Lines changed: 118 additions & 3 deletions

File tree

stovepipe/core/filter/filter.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright (c) 2025 Uber Technologies, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// Package filter implements a filter for commit events.
16+
package filter
17+
18+
import (
19+
"strings"
20+
21+
"github.com/uber/submitqueue/stovepipe/entity"
22+
)
23+
24+
// Config controls which VCS URIs are watched.
25+
// WatchedURIPrefixes is a list of URI prefixes to match against CommitEvent.URI.
26+
// Example: "git://github.com/uber/go-code/refs/heads/main"
27+
// watches all commits on the main branch of uber/go-code.
28+
type Config struct {
29+
WatchedURIPrefixes []string
30+
}
31+
32+
// ShouldProcess returns true if the commit event's URI matches
33+
// any of the configured watched prefixes.
34+
func ShouldProcess(cfg Config, event entity.CommitEvent) bool {
35+
for _, prefix := range cfg.WatchedURIPrefixes {
36+
if strings.HasPrefix(event.URI, prefix) {
37+
return true
38+
}
39+
}
40+
return false
41+
}

stovepipe/entity/entity.go

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,37 @@
44
// you may not use this file except in compliance with the License.
55
// You may obtain a copy of the License at
66
//
7-
// http://www.apache.org/licenses/LICENSE-2.0
7+
// http://www.apache.org/licenses/LICENSE-2.0
88
//
99
// Unless required by applicable law or agreed to in writing, software
1010
// distributed under the License is distributed on an "AS IS" BASIS,
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14-
15-
// Package entity holds Stovepipe-specific domain types (distinct from shared repo entity/).
1614
package entity
15+
16+
// CommitEvent represents a new commit detected on a VCS remote.
17+
// It is intentionally VCS-agnostic: the URI scheme carries the
18+
// provider identity, mirroring the github:// scheme used in
19+
// SubmitQueue's ChangeInfo.
20+
//
21+
// URI format: "git://<host>/<repo>/<ref>/<new-revision>"
22+
// Example: "git://github.com/uber/go-code/refs/heads/main/c3a4d5e6f789..."
23+
//
24+
// Fields are immutable after construction.
25+
type CommitEvent struct {
26+
// URI identifies the new commit state using a VCS-agnostic scheme.
27+
URI string `json:"uri"`
28+
// PriorURI identifies the prior state before this event. Empty if unknown. Scheme and host match URI.
29+
PreviousURI string `json:"previous_uri,omitempty"`
30+
// Author is the identity of the commit author or event initiator.
31+
Author Author `json:"author"`
32+
}
33+
34+
// Author identifies the person who authored a commit.
35+
type Author struct {
36+
// Name is the display name of the author.
37+
Name string `json:"name"`
38+
// Email is the email address of the author.
39+
Email string `json:"email,omitempty"`
40+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright (c) 2025 Uber Technologies, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// Package commitingester provides CommitEventHandler implementations.
16+
package commitingester
17+
18+
import (
19+
"context"
20+
21+
"github.com/uber/submitqueue/stovepipe/entity"
22+
)
23+
24+
// LoggingHandler is a stub CommitEventHandler that logs received commit events.
25+
// Replace with real DB/pipeline logic once schema is ready.
26+
type LoggingHandler struct{}
27+
28+
func (LoggingHandler) HandlePushEvent(ctx context.Context, event entity.PushEvent) error {
29+
// Caller (the Kafka consumer in go-code) is responsible for actual logging.
30+
// This stub is intentionally a no-op at the OSS layer.
31+
return nil
32+
}

stovepipe/extension/extension.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,21 @@
1414

1515
// Package extension holds Stovepipe-specific extension implementations.
1616
package extension
17+
18+
import (
19+
"context"
20+
21+
"github.com/uber/submitqueue/stovepipe/entity"
22+
)
23+
24+
// CommitIngester subscribes to commit events from a VCS source
25+
// and dispatches them for processing. The source and VCS are
26+
// implementation details left to the injected backend.
27+
type CommitIngester interface {
28+
Start(ctx context.Context) error
29+
}
30+
31+
// CommitEventHandler processes a single commit event received from the ingester.
32+
type CommitEventHandler interface {
33+
HandleCommitEvent(ctx context.Context, event entity.CommitEvent) error
34+
}

0 commit comments

Comments
 (0)