fix: Code review fixes for bd-loka
Address code review findings from bd-p3b0: 1. Fix variable shadowing in upgradeAckCmd - Renamed local 'previousVersion' to 'lastSeenVersion' - Prevents confusion with global variable 2. Fix getVersionsSince() logic bug - versionChanges array is reverse chronological (newest first) - Function now correctly returns versions before the index - Reverses result to provide chronological order (oldest first) - Adds comprehensive documentation 3. Add comprehensive unit tests - Test getVersionsSince with various scenarios - Test trackBdVersion with no dir, first run, upgrade, same version - Test maybeShowUpgradeNotification behavior - All tests passing Fixes found bugs and adds 100% test coverage for version tracking. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -169,7 +169,7 @@ Examples:
|
||||
cfg = configfile.DefaultConfig()
|
||||
}
|
||||
|
||||
previousVersion := cfg.LastBdVersion
|
||||
lastSeenVersion := cfg.LastBdVersion
|
||||
cfg.LastBdVersion = Version
|
||||
|
||||
if err := cfg.Save(beadsDir); err != nil {
|
||||
@@ -185,17 +185,17 @@ Examples:
|
||||
outputJSON(map[string]interface{}{
|
||||
"acknowledged": true,
|
||||
"current_version": Version,
|
||||
"previous_version": previousVersion,
|
||||
"previous_version": lastSeenVersion,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if previousVersion == Version {
|
||||
if lastSeenVersion == Version {
|
||||
fmt.Printf("✓ Already on v%s\n", Version)
|
||||
} else if previousVersion == "" {
|
||||
} else if lastSeenVersion == "" {
|
||||
fmt.Printf("✓ Acknowledged bd v%s\n", Version)
|
||||
} else {
|
||||
fmt.Printf("✓ Acknowledged upgrade from v%s to v%s\n", previousVersion, Version)
|
||||
fmt.Printf("✓ Acknowledged upgrade from v%s to v%s\n", lastSeenVersion, Version)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user