Skip to content

Commit 412218e

Browse files
authored
Rename the tags() functions of Repository and of WorkingCheckout as getTags(). This makes it more consistent with all the other functions, which have a verb at the start, but more importantly makes it easier for clients to adopt to the change (having a property change to a method without changing name makes it difficult for a type that adopts the protocol to conform to both). (#3100)
No change in functionality.
1 parent 33a2784 commit 412218e

File tree

11 files changed

+27
-27
lines changed

11 files changed

+27
-27
lines changed

Sources/PackageGraph/RepositoryPackageContainer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public class RepositoryPackageContainer: PackageContainer, CustomStringConvertib
9494
// Compute the map of known versions.
9595
private func knownVersions() throws -> [Version: String] {
9696
try self.knownVersionsCache.memoize() {
97-
let knownVersionsWithDuplicates = Git.convertTagsToVersionMap(try repository.tags())
97+
let knownVersionsWithDuplicates = Git.convertTagsToVersionMap(try repository.getTags())
9898

9999
return knownVersionsWithDuplicates.mapValues({ tags -> String in
100100
if tags.count == 2 {

Sources/SPMTestSupport/InMemoryGitRepository.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public final class InMemoryGitRepository {
5757
fileprivate var tagsMap: [String: RevisionIdentifier] = [:]
5858

5959
/// The array of current tags in the repository.
60-
public func tags() throws -> [String] {
60+
public func getTags() throws -> [String] {
6161
return Array(tagsMap.keys)
6262
}
6363

Sources/SourceControl/GitRepository.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ public final class GitRepository: Repository, WorkingCheckout {
320320
// MARK: Repository Interface
321321

322322
/// Returns the tags present in repository.
323-
public func tags() throws -> [String] {
323+
public func getTags() throws -> [String] {
324324
// Get the contents using `ls-tree`.
325325
try self.cachedTags.memoize {
326326
try self.queue.sync {

Sources/SourceControl/Repository.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ extension RepositoryProvider {
157157
/// an inconsistency can be detected.
158158
public protocol Repository {
159159
/// Get the list of tags in the repository.
160-
func tags() throws -> [String]
160+
func getTags() throws -> [String]
161161

162162
/// Resolve the revision for a specific tag.
163163
///
@@ -201,7 +201,7 @@ public protocol Repository {
201201
/// system.
202202
public protocol WorkingCheckout {
203203
/// Get the list of tags in the repository.
204-
func tags() throws -> [String]
204+
func getTags() throws -> [String]
205205

206206
/// Get the current revision.
207207
func getCurrentRevision() throws -> Revision

Tests/CommandsTests/PackageToolTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ final class PackageToolTests: XCTestCase {
136136
// Check that `resolve` works.
137137
_ = try execute(["resolve"], packagePath: packageRoot)
138138
let path = try SwiftPMProduct.packagePath(for: "Foo", packageRoot: packageRoot)
139-
XCTAssertEqual(try GitRepository(path: path).tags(), ["1.2.3"])
139+
XCTAssertEqual(try GitRepository(path: path).getTags(), ["1.2.3"])
140140
}
141141
}
142142

@@ -147,7 +147,7 @@ final class PackageToolTests: XCTestCase {
147147
// Perform an initial fetch.
148148
_ = try execute(["resolve"], packagePath: packageRoot)
149149
var path = try SwiftPMProduct.packagePath(for: "Foo", packageRoot: packageRoot)
150-
XCTAssertEqual(try GitRepository(path: path).tags(), ["1.2.3"])
150+
XCTAssertEqual(try GitRepository(path: path).getTags(), ["1.2.3"])
151151

152152
// Retag the dependency, and update.
153153
let repo = GitRepository(path: prefix.appending(component: "Foo"))
@@ -156,7 +156,7 @@ final class PackageToolTests: XCTestCase {
156156

157157
// We shouldn't assume package path will be same after an update so ask again for it.
158158
path = try SwiftPMProduct.packagePath(for: "Foo", packageRoot: packageRoot)
159-
XCTAssertEqual(try GitRepository(path: path).tags(), ["1.2.3", "1.2.4"])
159+
XCTAssertEqual(try GitRepository(path: path).getTags(), ["1.2.3", "1.2.4"])
160160
}
161161
}
162162

Tests/FunctionalTests/CFamilyTargetTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class CFamilyTargetTestCase: XCTestCase {
5050
XCTAssertDirectoryContainsFile(dir: debugPath, filename: "Sea.c.o")
5151
XCTAssertDirectoryContainsFile(dir: debugPath, filename: "Foo.c.o")
5252
let path = try SwiftPMProduct.packagePath(for: "Foo", packageRoot: packageRoot)
53-
XCTAssertEqual(try GitRepository(path: path).tags(), ["1.2.3"])
53+
XCTAssertEqual(try GitRepository(path: path).getTags(), ["1.2.3"])
5454
}
5555
}
5656

Tests/FunctionalTests/DependencyResolutionTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class DependencyResolutionTests: XCTestCase {
5454
XCTAssertBuilds(packageRoot)
5555
XCTAssertFileExists(prefix.appending(components: "Bar", ".build", Resources.default.toolchain.triple.tripleString, "debug", "Bar"))
5656
let path = try SwiftPMProduct.packagePath(for: "Foo", packageRoot: packageRoot)
57-
XCTAssert(try GitRepository(path: path).tags().contains("1.2.3"))
57+
XCTAssert(try GitRepository(path: path).getTags().contains("1.2.3"))
5858
}
5959
}
6060

Tests/PackageGraphTests/RepositoryPackageContainerProviderTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ private class MockRepository: Repository {
4242
return PackageReference(identity: PackageIdentity(url: self.url), path: self.url)
4343
}
4444

45-
func tags() throws -> [String] {
45+
func getTags() throws -> [String] {
4646
return self.versions.keys.map { String(describing: $0) }
4747
}
4848

Tests/SourceControlTests/GitRepositoryTests.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ class GitRepositoryTests: XCTestCase {
4747

4848
// Test the repository interface.
4949
let repository = provider.open(repository: repoSpec, at: testCheckoutPath)
50-
let tags = try repository.tags()
51-
XCTAssertEqual(try repository.tags(), ["1.2.3"])
50+
let tags = try repository.getTags()
51+
XCTAssertEqual(try repository.getTags(), ["1.2.3"])
5252

5353
let revision = try repository.resolveRevision(tag: tags.first ?? "<invalid>")
5454
// FIXME: It would be nice if we had a deterministic hash here...
@@ -300,21 +300,21 @@ class GitRepositoryTests: XCTestCase {
300300
try makeDirectories(testRepoPath)
301301
initGitRepo(testRepoPath, tag: "1.2.3")
302302
let repo = GitRepository(path: testRepoPath)
303-
XCTAssertEqual(try repo.tags(), ["1.2.3"])
303+
XCTAssertEqual(try repo.getTags(), ["1.2.3"])
304304

305305
// Clone it somewhere.
306306
let testClonePath = path.appending(component: "clone")
307307
let provider = GitRepositoryProvider()
308308
let repoSpec = RepositorySpecifier(url: testRepoPath.pathString)
309309
try provider.fetch(repository: repoSpec, to: testClonePath)
310310
let clonedRepo = provider.open(repository: repoSpec, at: testClonePath)
311-
XCTAssertEqual(try clonedRepo.tags(), ["1.2.3"])
311+
XCTAssertEqual(try clonedRepo.getTags(), ["1.2.3"])
312312

313313
// Clone off a checkout.
314314
let checkoutPath = path.appending(component: "checkout")
315315
try provider.cloneCheckout(repository: repoSpec, at: testClonePath, to: checkoutPath, editable: false)
316316
let checkoutRepo = try provider.openCheckout(at: checkoutPath)
317-
XCTAssertEqual(try checkoutRepo.tags(), ["1.2.3"])
317+
XCTAssertEqual(try checkoutRepo.getTags(), ["1.2.3"])
318318

319319
// Add a new file to original repo.
320320
try localFileSystem.writeFileContents(testRepoPath.appending(component: "test.txt"), bytes: "Hi")
@@ -325,11 +325,11 @@ class GitRepositoryTests: XCTestCase {
325325

326326
// Update the cloned repo.
327327
try clonedRepo.fetch()
328-
XCTAssertEqual(try clonedRepo.tags().sorted(), ["1.2.3", "2.0.0"])
328+
XCTAssertEqual(try clonedRepo.getTags().sorted(), ["1.2.3", "2.0.0"])
329329

330330
// Update the checkout.
331331
try checkoutRepo.fetch()
332-
XCTAssertEqual(try checkoutRepo.tags().sorted(), ["1.2.3", "2.0.0"])
332+
XCTAssertEqual(try checkoutRepo.getTags().sorted(), ["1.2.3", "2.0.0"])
333333
}
334334
}
335335

@@ -588,15 +588,15 @@ class GitRepositoryTests: XCTestCase {
588588
try makeDirectories(testRepoPath)
589589
initGitRepo(testRepoPath, tag: "1.2.3")
590590
let repo = GitRepository(path: testRepoPath)
591-
XCTAssertEqual(try repo.tags(), ["1.2.3"])
591+
XCTAssertEqual(try repo.getTags(), ["1.2.3"])
592592

593593
// Clone it somewhere.
594594
let testClonePath = path.appending(component: "clone")
595595
let provider = GitRepositoryProvider()
596596
let repoSpec = RepositorySpecifier(url: testRepoPath.pathString)
597597
try provider.fetch(repository: repoSpec, to: testClonePath)
598598
let clonedRepo = provider.open(repository: repoSpec, at: testClonePath)
599-
XCTAssertEqual(try clonedRepo.tags(), ["1.2.3"])
599+
XCTAssertEqual(try clonedRepo.getTags(), ["1.2.3"])
600600

601601
// Clone off a checkout.
602602
let checkoutPath = path.appending(component: "checkout")
@@ -670,7 +670,7 @@ class GitRepositoryTests: XCTestCase {
670670
let repoSpec = RepositorySpecifier(url: testRepoPath.pathString)
671671
try provider.fetch(repository: repoSpec, to: testClonePath)
672672
let clonedRepo = provider.open(repository: repoSpec, at: testClonePath)
673-
XCTAssertEqual(try clonedRepo.tags(), [])
673+
XCTAssertEqual(try clonedRepo.getTags(), [])
674674

675675
// Clone off a checkout.
676676
let checkoutPath = path.appending(component: "checkout")

Tests/SourceControlTests/InMemoryGitRepositoryTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ class InMemoryGitRepositoryTests: XCTestCase {
5656
XCTAssertTrue(!repo.hasUncommittedChanges())
5757
XCTAssertEqual(try repo.readFileContents(filePath), "two")
5858

59-
XCTAssert(try repo.tags().isEmpty)
59+
XCTAssert(try repo.getTags().isEmpty)
6060
try repo.tag(name: "2.0.0")
61-
XCTAssertEqual(try repo.tags(), ["2.0.0"])
61+
XCTAssertEqual(try repo.getTags(), ["2.0.0"])
6262
XCTAssertTrue(!repo.hasUncommittedChanges())
6363
XCTAssertEqual(try repo.readFileContents(filePath), "two")
6464
XCTAssertEqual(try fs.readFileContents(filePath), "two")
@@ -96,7 +96,7 @@ class InMemoryGitRepositoryTests: XCTestCase {
9696

9797
// Adding a new tag in original repo shouldn't show up in fetched repo.
9898
try repo.tag(name: "random")
99-
XCTAssertEqual(try fooRepo.tags().sorted(), [v1, v2])
99+
XCTAssertEqual(try fooRepo.getTags().sorted(), [v1, v2])
100100
XCTAssert(fooRepo.exists(revision: try fooRepo.resolveRevision(tag: v1)))
101101

102102
let fooCheckoutPath = AbsolutePath("/fooCheckout")
@@ -105,7 +105,7 @@ class InMemoryGitRepositoryTests: XCTestCase {
105105
XCTAssertTrue(try provider.checkoutExists(at: fooCheckoutPath))
106106
let fooCheckout = try provider.openCheckout(at: fooCheckoutPath)
107107

108-
XCTAssertEqual(try fooCheckout.tags().sorted(), [v1, v2])
108+
XCTAssertEqual(try fooCheckout.getTags().sorted(), [v1, v2])
109109
XCTAssert(fooCheckout.exists(revision: try fooCheckout.getCurrentRevision()))
110110
let checkoutRepo = provider.openRepo(at: fooCheckoutPath)
111111

Tests/SourceControlTests/RepositoryManagerTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ private class DummyRepository: Repository {
3232
self.provider = provider
3333
}
3434

35-
func tags() throws -> [String] {
35+
func getTags() throws -> [String] {
3636
["1.0.0"]
3737
}
3838

@@ -191,7 +191,7 @@ class RepositoryManagerTests: XCTestCase {
191191

192192
// Open the repository.
193193
let repository = try! handle.open()
194-
XCTAssertEqual(try! repository.tags(), ["1.0.0"])
194+
XCTAssertEqual(try! repository.getTags(), ["1.0.0"])
195195

196196
// Create a checkout of the repository.
197197
let checkoutPath = path.appending(component: "checkout")

0 commit comments

Comments
 (0)