Skip to content

Commit 389e49b

Browse files
committed
[Get] Use known version map to get appropriate tag.
- Instead of recomputing out of thin are the expected tag for a version, use the map established in the previous commit.
1 parent 8e12654 commit 389e49b

File tree

2 files changed

+3
-13
lines changed

2 files changed

+3
-13
lines changed

Sources/Get/RawClone.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,9 @@ class RawClone: Fetchable {
6565

6666
/// contract, you cannot call this before you have attempted to `constrain` this clone
6767
func setCurrentVersion(_ ver: Version) throws {
68-
let packageVersionsArePrefixed = repo.versionsArePrefixed
69-
let v = (packageVersionsArePrefixed ? "v" : "") + ver.description
70-
try Git.runCommandQuietly([Git.tool, "-C", path.asString, "reset", "--hard", v])
71-
try Git.runCommandQuietly([Git.tool, "-C", path.asString, "branch", "-m", v])
68+
let tag = repo.knownVersions[ver]!
69+
try Git.runCommandQuietly([Git.tool, "-C", path.asString, "reset", "--hard", tag])
70+
try Git.runCommandQuietly([Git.tool, "-C", path.asString, "branch", "-m", tag])
7271

7372
print("Resolved version:", ver)
7473

Sources/Utility/Git.swift

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,6 @@ public class Git {
102102
return !(changes?.isEmpty ?? true)
103103
}
104104

105-
/**
106-
- Returns: true if the package versions in this repository
107-
are all prefixed with "v", otherwise false. If there are
108-
no versions, returns false.
109-
*/
110-
public var versionsArePrefixed: Bool {
111-
return (try? Git.runPopen([Git.tool, "-C", path.asString, "tag", "-l"]))?.hasPrefix("v") ?? false
112-
}
113-
114105
public func fetch() throws {
115106
#if os(Linux)
116107
try system(Git.tool, "-C", path.asString, "fetch", "--tags", "origin", environment: ProcessInfo.processInfo().environment, message: nil)

0 commit comments

Comments
 (0)