Trim comments to the non-obvious why
Test and deploy / test (push) Successful in 28s
Test and deploy / deploy (push) Successful in 31s

Drop narration, history and restated-code comments across the repo,
keep short ones for security boundaries, upstream quirks and ordering
constraints, and record the convention in CLAUDE.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-11-24 20:49:03 +00:00
co-authored by Claude Opus 5.5
parent effddd2794
commit 4530cb8dc4
222 changed files with 1173 additions and 5423 deletions
+7 -23
View File
@@ -8,35 +8,27 @@ import (
"time"
)
// This file talks to the self-hosted Gitea instance over the private Docker
// network to surface "what did Adam push most recently" on the home page.
// The response is cached by the caller (handlers.Store, 1 minute TTL).
// The latest Gitea push, for the home page.
// GiteaFeedCommit is one commit inside a push event's Content payload.
// The capitalised JSON keys are Gitea's, not a typo.
// Gitea's own capitalised keys.
type GiteaFeedCommit struct {
Message string `json:"Message"`
}
// GiteaFeedContent is the shape of the JSON *string* stored in
// GiteaFeedResponse.Content for push events; see ParseCommitMessage.
// Push events' Content is this, as a JSON string; see ParseCommitMessage.
type GiteaFeedContent struct {
Commits []GiteaFeedCommit `json:"Commits"`
}
// GiteaFeedUser is the acting user on a feed entry.
type GiteaFeedUser struct {
AvatarURL string `json:"avatar_url"`
}
// GiteaFeedRepo is the repository a feed entry belongs to.
type GiteaFeedRepo struct {
FullName string `json:"full_name"`
HTMLURL string `json:"html_url"`
}
// GiteaFeedResponse is a single Gitea activity feed entry. Only the fields
// the front end renders are declared; the rest of the payload is discarded.
type GiteaFeedResponse struct {
ActUser GiteaFeedUser `json:"act_user"`
Repo GiteaFeedRepo `json:"repo"`
@@ -45,13 +37,8 @@ type GiteaFeedResponse struct {
Created time.Time `json:"created"`
}
// FetchLatestFeed returns the single most recent public activity entry for
// user "adamf", or (nil, nil) when the feed is empty — callers must handle
// that nil-without-error case.
//
// The username is hard-coded and the call is plain HTTP with no token: this
// only ever reaches the Gitea container over the internal Docker network,
// where the public feed needs no authentication.
// FetchLatestFeed returns (nil, nil) for an empty feed. Unauthenticated: the
// public feed needs no token.
func FetchLatestFeed(host, port string) (*GiteaFeedResponse, error) {
url := fmt.Sprintf("http://%s:%s/api/v1/users/adamf/activities/feeds?limit=1", host, port)
@@ -79,11 +66,8 @@ func FetchLatestFeed(host, port string) (*GiteaFeedResponse, error) {
return &items[0], nil
}
// ParseCommitMessage pulls the first commit message out of a feed entry's
// Content field, which Gitea delivers as JSON encoded inside a JSON string
// (so it needs a second Unmarshal). Non-push events have Content in a
// different shape entirely, so any parse failure is intentionally swallowed
// and reported as "no commit message".
// ParseCommitMessage decodes JSON-in-a-string. Non-push events don't parse,
// which yields "".
func ParseCommitMessage(content string) string {
var c GiteaFeedContent
if err := json.Unmarshal([]byte(content), &c); err != nil {