feat: the changelog in the status pane, built in
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
56d3d25c9c
commit
dc856677cc
8 files changed
+84
-4
No files matched your search
@@ -94,7 +94,7 @@ func (m Model) statusFields() []panes.Field {
|
||||
add(panes.Field{Label: "docs", Value: repo + "/…/docs", URL: update.DefaultRepo + "/src/branch/main/docs"})
|
||||
add(panes.Field{Label: "source", Value: repo, URL: update.DefaultRepo})
|
||||
add(panes.Field{Label: "issues", Value: repo + "/issues", URL: update.DefaultRepo + "/issues"})
|
||||
return out
|
||||
return append(out, m.changelog...)
|
||||
}
|
||||
|
||||
// updateStatus says whether a newer release is out, and when it was
|
||||
@@ -141,3 +141,31 @@ func ago(d time.Duration) string {
|
||||
}
|
||||
return fmt.Sprintf("%dd ago", int(d.Hours()/24))
|
||||
}
|
||||
|
||||
// changelogFields are CHANGELOG.md as rows: each release's version and
|
||||
// date, then its entries, marked by what kind they are.
|
||||
func changelogFields(md string) []panes.Field {
|
||||
var out []panes.Field
|
||||
kind := ""
|
||||
for _, line := range strings.Split(md, "\n") {
|
||||
line = strings.TrimSpace(line)
|
||||
switch {
|
||||
case strings.HasPrefix(line, "## "):
|
||||
version, date, _ := strings.Cut(strings.TrimPrefix(line, "## "), " – ")
|
||||
out = append(out, panes.Field{Label: version, Value: date, Info: true})
|
||||
kind = ""
|
||||
case strings.HasPrefix(line, "### "):
|
||||
kind = strings.ToLower(strings.TrimPrefix(line, "### "))
|
||||
case strings.HasPrefix(line, "- ") && len(out) > 0:
|
||||
text := update.PlainLinks(strings.TrimPrefix(line, "- "))
|
||||
if kind != "" {
|
||||
text = kind + ": " + text
|
||||
}
|
||||
out = append(out, panes.Field{Value: text})
|
||||
case line != "" && len(out) > 0 && !strings.HasPrefix(line, "<!--"):
|
||||
// A release's own words ("Hello world 👋").
|
||||
out = append(out, panes.Field{Value: update.PlainLinks(line)})
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
Reference in new issue
Block a user