Merge pull request #1923 from ksylvan/kayvan/fix-generate-changelog-db-sync-issues

ChangeLog Generation stability
This commit is contained in:
Kayvan Sylvan
2026-01-04 11:22:43 -08:00
committed by GitHub
3 changed files with 24 additions and 7 deletions

View File

@@ -0,0 +1,7 @@
### PR [#1923](https://github.com/danielmiessler/Fabric/pull/1923) by [ksylvan](https://github.com/ksylvan): ChangeLog Generation stability
- Fix: improve date parsing and prevent early return when PR numbers exist
- Add SQLite datetime formats to version date parsing logic
- Loop through multiple date formats until one succeeds
- Include SQLite fractional seconds format support
- Prevent early return when version has PR numbers to output

View File

@@ -202,14 +202,23 @@ func (c *Cache) GetVersions() (map[string]*git.Version, error) {
} }
if dateStr.Valid { if dateStr.Valid {
// Try RFC3339Nano first (for nanosecond precision), then fall back to RFC3339 // Try multiple date formats: SQLite format, RFC3339Nano, and RFC3339
v.Date, err = time.Parse(time.RFC3339Nano, dateStr.String) dateFormats := []string{
if err != nil { "2006-01-02 15:04:05-07:00", // SQLite DATETIME format
v.Date, err = time.Parse(time.RFC3339, dateStr.String) "2006-01-02 15:04:05.999999999-07:00", // SQLite with fractional seconds
if err != nil { time.RFC3339Nano,
fmt.Fprintf(os.Stderr, "Error parsing date '%s' for version '%s': %v. Expected format: RFC3339 or RFC3339Nano.\n", dateStr.String, v.Name, err) time.RFC3339,
}
var parseErr error
for _, format := range dateFormats {
v.Date, parseErr = time.Parse(format, dateStr.String)
if parseErr == nil {
break // Successfully parsed
} }
} }
if parseErr != nil {
fmt.Fprintf(os.Stderr, "Error parsing date '%s' for version '%s': %v\n", dateStr.String, v.Name, parseErr)
}
} }
if prNumbersJSON != "" { if prNumbersJSON != "" {

View File

@@ -470,7 +470,8 @@ func (g *Generator) generateRawVersionContent(version *git.Version) string {
} }
// There are occasionally no PRs or direct commits other than version bumps, so we handle that gracefully // There are occasionally no PRs or direct commits other than version bumps, so we handle that gracefully
if len(prCommits) == 0 && len(directCommits) == 0 { // However, don't return early if we have PRs to output from version.PRNumbers
if len(prCommits) == 0 && len(directCommits) == 0 && len(version.PRNumbers) == 0 {
return "" return ""
} }