MCPcopy Index your code
hub / github.com/coder/coder / updateCalendarFile

Function updateCalendarFile

scripts/releaser/docs.go:280–309  ·  view source on GitHub ↗

updateCalendarFile reads the releases index.md, updates the calendar table, and writes it back.

(
	repoRoot string,
	newVer version,
	channel string,
)

Source from the content-addressed store, hash-verified

278// updateCalendarFile reads the releases index.md, updates the
279// calendar table, and writes it back.
280func updateCalendarFile(
281 repoRoot string,
282 newVer version,
283 channel string,
284) error {
285 path := filepath.Join(repoRoot, releasesFile)
286 content, err := os.ReadFile(path)
287 if err != nil {
288 return xerrors.Errorf("reading %s: %w", releasesFile, err)
289 }
290
291 rows, err := parseCalendarTable(string(content))
292 if err != nil {
293 return xerrors.Errorf("parsing calendar: %w", err)
294 }
295
296 rows = updateCalendar(rows, newVer, channel)
297 newTable := renderCalendarTable(rows)
298
299 // Replace the content between markers.
300 s := string(content)
301 startIdx := strings.Index(s, calendarStartMarker)
302 endIdx := strings.Index(s, calendarEndMarker)
303 updated := s[:startIdx+len(calendarStartMarker)] +
304 "\n" + newTable +
305 s[endIdx:]
306
307 //nolint:gosec // File permissions match the original.
308 return os.WriteFile(path, []byte(updated), 0o644)
309}
310
311// updateAutoversionFile reads a markdown file and replaces
312// version strings in lines following autoversion pragmas for

Callers 1

updateReleaseDocsFunction · 0.85

Calls 6

parseCalendarTableFunction · 0.85
updateCalendarFunction · 0.85
renderCalendarTableFunction · 0.85
ReadFileMethod · 0.65
WriteFileMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected