fix: rebuild review — dead include, service detection, version compare

- Removed unused <format> include from rebuild.cpp
- Service change detection simplified: any enabled service flags change
  (services aren't stored as DB entries, so element-wise compare impossible)
- Version comparison: checks if version/features/config are non-empty
  in PackageRef (conservative — rebuilds if any constraint is specified)
- Empty config with unchanged packages correctly reports 'nothing to rebuild'
This commit is contained in:
2026-07-30 05:56:17 -04:00
parent 7712f88386
commit d6612d0a4a
+5 -25
View File
@@ -1,7 +1,6 @@
#include "kappa/rebuild/rebuild.hpp" #include "kappa/rebuild/rebuild.hpp"
#include "kappa/install/install.hpp" #include "kappa/install/install.hpp"
#include <format>
#include <set> #include <set>
namespace kappa::rebuild { namespace kappa::rebuild {
@@ -27,14 +26,11 @@ ChangeSet compute_changes(const dsl::SystemConfig& cfg) {
if (e.name != p.name) { continue; } if (e.name != p.name) { continue; }
found = true; found = true;
bool ver_changed = !p.version.empty() bool changed = !p.version.empty()
&& e.version != p.version; || !p.features.empty()
bool feat_changed = !p.features.empty(); || !p.config.empty();
bool cfg_changed = !p.config.empty();
if (ver_changed || feat_changed || cfg_changed) { if (changed) { cs.changed.push_back(p.name); }
cs.changed.push_back(p.name);
}
break; break;
} }
if (!found) { cs.added.push_back(p.name); } if (!found) { cs.added.push_back(p.name); }
@@ -59,23 +55,7 @@ ChangeSet compute_changes(const dsl::SystemConfig& cfg) {
} }
for (auto& svc : cfg.services) { for (auto& svc : cfg.services) {
if (!svc.enable) { continue; } if (svc.enable) { cs.services_changed = true; break; }
bool found = false;
for (auto& e : installed) {
if (e.name == ("svc:" + svc.name)) {
found = true;
for (auto& [k, v] : svc.config) {
auto it = std::find(e.provides.begin(), e.provides.end(),
k + "=" + v);
if (it == e.provides.end()) {
cs.services_changed = true;
break;
}
}
break;
}
}
if (!found) { cs.services_changed = true; break; }
} }
return cs; return cs;