Skip to content

Commit 21c3e51

Browse files
committed
Re-read the manifest if the version changes
Since the manifest may be different for each and every version tag. Ideally we’d do some caching here, (with llbuild).
1 parent f6b6da9 commit 21c3e51

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Sources/dep/get.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,15 @@ extension Sandbox: Fetcher {
137137

138138
// lazy because the tip of the default branch does not have to be a valid package
139139
//FIXME we should error gracefully if a selected version does not however
140-
lazy var manifest: Manifest = try! Manifest(path: Path.join(self.path, Manifest.filename), baseURL: self.repo.origin!)
140+
var manifest: Manifest! {
141+
if let manifest = _manifest {
142+
return manifest
143+
} else {
144+
_manifest = try? Manifest(path: Path.join(path, Manifest.filename), baseURL: repo.origin!)
145+
return _manifest
146+
}
147+
}
148+
private var _manifest: Manifest?
141149

142150
init(path: String) {
143151
self.path = path
@@ -164,6 +172,9 @@ extension Sandbox: Fetcher {
164172
let v = (packageVersionsArePrefixed ? "v" : "") + v.description
165173
try popen([Git.tool, "-C", path, "reset", "--hard", v])
166174
try popen([Git.tool, "-C", path, "branch", "-m", v])
175+
176+
// we must re-read the manifest
177+
_manifest = nil
167178
}
168179

169180
func constrain(to versionRange: Range<Version>) -> Version? {

0 commit comments

Comments
 (0)