File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 11
11
import Basic
12
12
13
13
/// Specifies a repository address.
14
- public struct RepositorySpecifier {
14
+ public struct RepositorySpecifier : Hashable {
15
15
/// The URL of the repository.
16
16
public let url : String
17
17
@@ -31,6 +31,13 @@ public struct RepositorySpecifier {
31
31
let basename = url. components ( separatedBy: " / " ) . last!
32
32
return basename + " - " + String( url. hashValue)
33
33
}
34
+
35
+ public var hashValue : Int {
36
+ return url. hashValue
37
+ }
38
+ }
39
+ public func == ( lhs: RepositorySpecifier , rhs: RepositorySpecifier ) -> Bool {
40
+ return lhs. url == rhs. url
34
41
}
35
42
36
43
/// A repository provider.
Original file line number Diff line number Diff line change @@ -19,6 +19,17 @@ import TestSupport
19
19
@testable import class SourceControl. GitRepository
20
20
21
21
class GitRepositoryTests : XCTestCase {
22
+ /// Test the basic provider functions.
23
+ func testRepositorySpecifier( ) {
24
+ let a = RepositorySpecifier ( url: " a " )
25
+ let b = RepositorySpecifier ( url: " b " )
26
+ let a2 = RepositorySpecifier ( url: " a " )
27
+ XCTAssertEqual ( a, a)
28
+ XCTAssertNotEqual ( a, b)
29
+ XCTAssertEqual ( a, a2)
30
+ XCTAssertEqual ( Set ( [ a] ) , Set ( [ a2] ) )
31
+ }
32
+
22
33
/// Test the basic provider functions.
23
34
func testProvider( ) throws {
24
35
mktmpdir { path in
@@ -185,6 +196,7 @@ class GitRepositoryTests: XCTestCase {
185
196
}
186
197
187
198
static var allTests = [
199
+ ( " testRepositorySpecifier " , testRepositorySpecifier) ,
188
200
( " testProvider " , testProvider) ,
189
201
( " testGitRepositoryHash " , testGitRepositoryHash) ,
190
202
( " testRawRepository " , testRawRepository) ,
You can’t perform that action at this time.
0 commit comments