Quality: Lockfile entry is discarded for matching URLs due to inverted comparison#1106
Conversation
…ed comparison `Repo.__init__` only keeps `locked_version` when `locked_version.url != url.geturl()`. This is inverted: lock data is retained when URLs differ and dropped when they match. That can silently clear valid lock state and lead to unnecessary re-prefetch/re-evaluation or incorrect update behavior. Affected files: manifest.py Signed-off-by: Nguyen Van Nam <nam.nv205106@gmail.com>
|
Correct me if I'm wrong, but I'm pretty sure the logic here is right. If we're passing a repository and the URL has changed, we want to copy over the new locked version. |
|
Thanks for taking a look at this. I might be missing some intended behavior here, but from reading If that's right, then the current condition seems a little counter-intuitive: it keeps the old lock when the URL changed, and drops it when the URL still matches. My gut feeling is that reusing the old lock only makes sense when it still points to the same source ( So to me, Happy to be corrcted if I'm overlooking that part. |
|
Sounds reasonable. Could you figure out what's causing the failed test? |
✨ Code Quality
Problem
Repo.__init__only keepslocked_versionwhenlocked_version.url != url.geturl(). This is inverted: lock data is retained when URLs differ and dropped when they match. That can silently clear valid lock state and lead to unnecessary re-prefetch/re-evaluation or incorrect update behavior.Severity:
highFile:
ci/nur/manifest.pySolution
Flip the URL comparison so lock state is preserved only when it matches the repo definition:
if ( locked_version is not None and locked_version.url == url.geturl() and locked_version.submodules == submodules ): self.locked_version = locked_versionChanges
ci/nur/manifest.py(modified)The following points apply when adding a new repository to repos.json
./bin/nur format-manifestafter updatingrepos.json(We will use the same script in github actions to make sure we keep the format consistent)meta.licenseandmeta.sourceProvenancehave been set correctly for any derivations for unfree or not built from source packagesAdditionally, the following points are recommended:
metafields have been filled out. See https://nixos.org/manual/nixpkgs/stable/#sec-standard-meta-attributes for more information. The following fields are particularly helpful and can always be filled out:meta.description, so consumers can confirm that that your package is what they're looking formeta.license, even for free packagesmeta.homepage, for tracking and deduplicationmeta.mainProgram, so thatnix runworks correctlyCloses #1105