A vibe coded tangled fork which supports pijul.

appview/notify: add Clone notifier, enqueue posthog event for clones

Signed-off-by: Anirudh Oppiliappan <anirudh@tangled.org>

authored by

Anirudh Oppiliappan and committed by tangled.org 88b2cbf2 8345797d

+32
+4
appview/notify/db/db.go
··· 361 361 // no-op for now; webhooks are handled by the webhook notifier 362 362 } 363 363 364 + func (n *databaseNotifier) Clone(ctx context.Context, repo *models.Repo) { 365 + // no-op 366 + } 367 + 364 368 func (n *databaseNotifier) NewIssueState(ctx context.Context, actor syntax.DID, issue *models.Issue) { 365 369 l := log.FromContext(ctx) 366 370
+5
appview/notify/logging_notifier.go
··· 118 118 ctx = tlog.IntoContext(ctx, tlog.SubLogger(l.logger, "Push")) 119 119 l.inner.Push(ctx, repo, ref, oldSha, newSha, committerDid) 120 120 } 121 + 122 + func (l *loggingNotifier) Clone(ctx context.Context, repo *models.Repo) { 123 + ctx = tlog.IntoContext(ctx, tlog.SubLogger(l.logger, "Clone")) 124 + l.inner.Clone(ctx, repo) 125 + }
+4
appview/notify/merged_notifier.go
··· 105 105 func (m *mergedNotifier) Push(ctx context.Context, repo *models.Repo, ref, oldSha, newSha, committerDid string) { 106 106 m.fanout(func(n Notifier) { n.Push(ctx, repo, ref, oldSha, newSha, committerDid) }) 107 107 } 108 + 109 + func (m *mergedNotifier) Clone(ctx context.Context, repo *models.Repo) { 110 + m.fanout(func(n Notifier) { n.Clone(ctx, repo) }) 111 + }
+4
appview/notify/notifier.go
··· 35 35 DeleteString(ctx context.Context, did, rkey string) 36 36 37 37 Push(ctx context.Context, repo *models.Repo, ref, oldSha, newSha, committerDid string) 38 + 39 + Clone(ctx context.Context, repo *models.Repo) 38 40 } 39 41 40 42 // BaseNotifier is a listener that does nothing ··· 72 74 73 75 func (m *BaseNotifier) Push(ctx context.Context, repo *models.Repo, ref, oldSha, newSha, committerDid string) { 74 76 } 77 + 78 + func (m *BaseNotifier) Clone(ctx context.Context, repo *models.Repo) {}
+11
appview/notify/posthog/notifier.go
··· 180 180 } 181 181 } 182 182 183 + func (n *posthogNotifier) Clone(ctx context.Context, repo *models.Repo) { 184 + err := n.client.Enqueue(posthog.Capture{ 185 + DistinctId: repo.Did, 186 + Event: "clone", 187 + Properties: posthog.Properties{"repo": repo.Name, "repo_at": repo.RepoAt()}, 188 + }) 189 + if err != nil { 190 + log.Println("failed to enqueue posthog event:", err) 191 + } 192 + } 193 + 183 194 func (n *posthogNotifier) NewIssueComment(ctx context.Context, comment *models.IssueComment, mentions []syntax.DID) { 184 195 err := n.client.Enqueue(posthog.Capture{ 185 196 DistinctId: comment.Did,
+2
appview/notify/webhook_notifier.go
··· 69 69 } 70 70 } 71 71 72 + func (w *WebhookNotifier) Clone(ctx context.Context, repo *models.Repo) {} 73 + 72 74 // buildPushPayload creates the webhook payload 73 75 func (w *WebhookNotifier) buildPushPayload(repo *models.Repo, ref, oldSha, newSha, committerDid string) (*models.WebhookPayload, error) { 74 76 owner := repo.Did
+2
appview/state/git_http.go
··· 1 1 package state 2 2 3 3 import ( 4 + "context" 4 5 "fmt" 5 6 "io" 6 7 "net/http" ··· 51 52 contentType = "application/x-git-receive-pack-advertisement" 52 53 default: 53 54 contentType = "application/x-git-upload-pack-advertisement" 55 + go s.notifier.Clone(context.Background(), repo) 54 56 } 55 57 56 58 targetURL := fmt.Sprintf("%s://%s/%s/info/refs?%s", scheme, repo.Knot, repo.RepoIdentifier(), r.URL.RawQuery)