Skip to content

Rename the tags() functions of Repository and of WorkingCheckout to getTags() #3100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/PackageGraph/RepositoryPackageContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public class RepositoryPackageContainer: PackageContainer, CustomStringConvertib
// Compute the map of known versions.
private func knownVersions() throws -> [Version: String] {
try self.knownVersionsCache.memoize() {
let knownVersionsWithDuplicates = Git.convertTagsToVersionMap(try repository.tags())
let knownVersionsWithDuplicates = Git.convertTagsToVersionMap(try repository.getTags())

return knownVersionsWithDuplicates.mapValues({ tags -> String in
if tags.count == 2 {
Expand Down
2 changes: 1 addition & 1 deletion Sources/SPMTestSupport/InMemoryGitRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public final class InMemoryGitRepository {
fileprivate var tagsMap: [String: RevisionIdentifier] = [:]

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

Expand Down
2 changes: 1 addition & 1 deletion Sources/SourceControl/GitRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ public final class GitRepository: Repository, WorkingCheckout {
// MARK: Repository Interface

/// Returns the tags present in repository.
public func tags() throws -> [String] {
public func getTags() throws -> [String] {
// Get the contents using `ls-tree`.
try self.cachedTags.memoize {
try self.queue.sync {
Expand Down
4 changes: 2 additions & 2 deletions Sources/SourceControl/Repository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ extension RepositoryProvider {
/// an inconsistency can be detected.
public protocol Repository {
/// Get the list of tags in the repository.
func tags() throws -> [String]
func getTags() throws -> [String]

/// Resolve the revision for a specific tag.
///
Expand Down Expand Up @@ -201,7 +201,7 @@ public protocol Repository {
/// system.
public protocol WorkingCheckout {
/// Get the list of tags in the repository.
func tags() throws -> [String]
func getTags() throws -> [String]

/// Get the current revision.
func getCurrentRevision() throws -> Revision
Expand Down
6 changes: 3 additions & 3 deletions Tests/CommandsTests/PackageToolTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ final class PackageToolTests: XCTestCase {
// Check that `resolve` works.
_ = try execute(["resolve"], packagePath: packageRoot)
let path = try SwiftPMProduct.packagePath(for: "Foo", packageRoot: packageRoot)
XCTAssertEqual(try GitRepository(path: path).tags(), ["1.2.3"])
XCTAssertEqual(try GitRepository(path: path).getTags(), ["1.2.3"])
}
}

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

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

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

Expand Down
2 changes: 1 addition & 1 deletion Tests/FunctionalTests/CFamilyTargetTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class CFamilyTargetTestCase: XCTestCase {
XCTAssertDirectoryContainsFile(dir: debugPath, filename: "Sea.c.o")
XCTAssertDirectoryContainsFile(dir: debugPath, filename: "Foo.c.o")
let path = try SwiftPMProduct.packagePath(for: "Foo", packageRoot: packageRoot)
XCTAssertEqual(try GitRepository(path: path).tags(), ["1.2.3"])
XCTAssertEqual(try GitRepository(path: path).getTags(), ["1.2.3"])
}
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/FunctionalTests/DependencyResolutionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class DependencyResolutionTests: XCTestCase {
XCTAssertBuilds(packageRoot)
XCTAssertFileExists(prefix.appending(components: "Bar", ".build", Resources.default.toolchain.triple.tripleString, "debug", "Bar"))
let path = try SwiftPMProduct.packagePath(for: "Foo", packageRoot: packageRoot)
XCTAssert(try GitRepository(path: path).tags().contains("1.2.3"))
XCTAssert(try GitRepository(path: path).getTags().contains("1.2.3"))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private class MockRepository: Repository {
return PackageReference(identity: PackageIdentity(url: self.url), path: self.url)
}

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

Expand Down
20 changes: 10 additions & 10 deletions Tests/SourceControlTests/GitRepositoryTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ class GitRepositoryTests: XCTestCase {

// Test the repository interface.
let repository = provider.open(repository: repoSpec, at: testCheckoutPath)
let tags = try repository.tags()
XCTAssertEqual(try repository.tags(), ["1.2.3"])
let tags = try repository.getTags()
XCTAssertEqual(try repository.getTags(), ["1.2.3"])

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

// Clone it somewhere.
let testClonePath = path.appending(component: "clone")
let provider = GitRepositoryProvider()
let repoSpec = RepositorySpecifier(url: testRepoPath.pathString)
try provider.fetch(repository: repoSpec, to: testClonePath)
let clonedRepo = provider.open(repository: repoSpec, at: testClonePath)
XCTAssertEqual(try clonedRepo.tags(), ["1.2.3"])
XCTAssertEqual(try clonedRepo.getTags(), ["1.2.3"])

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

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

// Update the cloned repo.
try clonedRepo.fetch()
XCTAssertEqual(try clonedRepo.tags().sorted(), ["1.2.3", "2.0.0"])
XCTAssertEqual(try clonedRepo.getTags().sorted(), ["1.2.3", "2.0.0"])

// Update the checkout.
try checkoutRepo.fetch()
XCTAssertEqual(try checkoutRepo.tags().sorted(), ["1.2.3", "2.0.0"])
XCTAssertEqual(try checkoutRepo.getTags().sorted(), ["1.2.3", "2.0.0"])
}
}

Expand Down Expand Up @@ -588,15 +588,15 @@ class GitRepositoryTests: XCTestCase {
try makeDirectories(testRepoPath)
initGitRepo(testRepoPath, tag: "1.2.3")
let repo = GitRepository(path: testRepoPath)
XCTAssertEqual(try repo.tags(), ["1.2.3"])
XCTAssertEqual(try repo.getTags(), ["1.2.3"])

// Clone it somewhere.
let testClonePath = path.appending(component: "clone")
let provider = GitRepositoryProvider()
let repoSpec = RepositorySpecifier(url: testRepoPath.pathString)
try provider.fetch(repository: repoSpec, to: testClonePath)
let clonedRepo = provider.open(repository: repoSpec, at: testClonePath)
XCTAssertEqual(try clonedRepo.tags(), ["1.2.3"])
XCTAssertEqual(try clonedRepo.getTags(), ["1.2.3"])

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

// Clone off a checkout.
let checkoutPath = path.appending(component: "checkout")
Expand Down
8 changes: 4 additions & 4 deletions Tests/SourceControlTests/InMemoryGitRepositoryTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ class InMemoryGitRepositoryTests: XCTestCase {
XCTAssertTrue(!repo.hasUncommittedChanges())
XCTAssertEqual(try repo.readFileContents(filePath), "two")

XCTAssert(try repo.tags().isEmpty)
XCTAssert(try repo.getTags().isEmpty)
try repo.tag(name: "2.0.0")
XCTAssertEqual(try repo.tags(), ["2.0.0"])
XCTAssertEqual(try repo.getTags(), ["2.0.0"])
XCTAssertTrue(!repo.hasUncommittedChanges())
XCTAssertEqual(try repo.readFileContents(filePath), "two")
XCTAssertEqual(try fs.readFileContents(filePath), "two")
Expand Down Expand Up @@ -96,7 +96,7 @@ class InMemoryGitRepositoryTests: XCTestCase {

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

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

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

Expand Down
4 changes: 2 additions & 2 deletions Tests/SourceControlTests/RepositoryManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private class DummyRepository: Repository {
self.provider = provider
}

func tags() throws -> [String] {
func getTags() throws -> [String] {
["1.0.0"]
}

Expand Down Expand Up @@ -191,7 +191,7 @@ class RepositoryManagerTests: XCTestCase {

// Open the repository.
let repository = try! handle.open()
XCTAssertEqual(try! repository.tags(), ["1.0.0"])
XCTAssertEqual(try! repository.getTags(), ["1.0.0"])

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