swiftlang / swift-package-manager

The Package Manager for the Swift Programming Language
Apache License 2.0
9.72k stars 1.34k forks source link

V3 `originHash` should update more eagerly #7644

Open pyrtsa opened 3 months ago

pyrtsa commented 3 months ago

Description

The new v3 pin file format for Package.resolved introduced a new key originHash, which appears to be a SHA-256 checksum of local package files (often just shasum -a 256 Package.swift). The hash is recomputed whenever calling swift package update [...], however the new value is only written to disk when the dependency graph was changed as a result.

Often when editing the package file or when merging changes from branches which do so, the originHash value is left in a state not reflecting the merged result, and by surprise the pin file only changes at a later time.

I think it would be ideal if swift package update [...] made sure to update the originHash even if no package dependency got changed.

(It would also be nice if the package resolution automatic triggered by Xcode made sure to keep originHash up to date. I don't know which precise SwiftPM command it corresponds to; swift package resolve maybe? See related thread in Developer Forums.)

Expected behavior

No response

Actual behavior

No response

Steps to reproduce

No response

Swift Package Manager version/commit hash

No response

Swift & OS version (output of swift --version && uname -a)

No response