Skip to content
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

Make Servers and Repositorys case insensitive #22

Merged
merged 2 commits into from
Mar 21, 2016
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
12 changes: 12 additions & 0 deletions Tentacle.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@
BE88E84D1C88E6D60034A112 /* Argo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BE88E84B1C88E6D60034A112 /* Argo.framework */; };
BE88E84E1C88E6D60034A112 /* Curry.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BE88E84C1C88E6D60034A112 /* Curry.framework */; };
BE88E8751C88F0C50034A112 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE88E8741C88F0C50034A112 /* main.swift */; };
BEA86F9A1C9F7C230049360B /* ServerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEA86F991C9F7C230049360B /* ServerTests.swift */; };
BEA86F9B1C9F7C230049360B /* ServerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEA86F991C9F7C230049360B /* ServerTests.swift */; };
BEA86F9D1C9F7E1E0049360B /* RepositoryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEA86F9C1C9F7E1E0049360B /* RepositoryTests.swift */; };
BEA86F9E1C9F7E1E0049360B /* RepositoryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEA86F9C1C9F7E1E0049360B /* RepositoryTests.swift */; };
BEAB175B1C9D0AB7009F8F58 /* repos-mdiep-MDPSplitView-releases-assets-433845.data in Resources */ = {isa = PBXBuildFile; fileRef = BEAB17571C9D062D009F8F58 /* repos-mdiep-MDPSplitView-releases-assets-433845.data */; };
BEAB175C1C9D0AB7009F8F58 /* repos-mdiep-MDPSplitView-releases-assets-433845.response in Resources */ = {isa = PBXBuildFile; fileRef = BEAB17581C9D062D009F8F58 /* repos-mdiep-MDPSplitView-releases-assets-433845.response */; };
BEAB175D1C9D0AB8009F8F58 /* repos-mdiep-MDPSplitView-releases-assets-433845.data in Resources */ = {isa = PBXBuildFile; fileRef = BEAB17571C9D062D009F8F58 /* repos-mdiep-MDPSplitView-releases-assets-433845.data */; };
Expand Down Expand Up @@ -142,6 +146,8 @@
BE88E8671C88F0990034A112 /* update-test-fixtures.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "update-test-fixtures.app"; sourceTree = BUILT_PRODUCTS_DIR; };
BE88E8701C88F0990034A112 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
BE88E8741C88F0C50034A112 /* main.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
BEA86F991C9F7C230049360B /* ServerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ServerTests.swift; sourceTree = "<group>"; };
BEA86F9C1C9F7E1E0049360B /* RepositoryTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RepositoryTests.swift; sourceTree = "<group>"; };
BEAB17571C9D062D009F8F58 /* repos-mdiep-MDPSplitView-releases-assets-433845.data */ = {isa = PBXFileReference; lastKnownFileType = file; path = "repos-mdiep-MDPSplitView-releases-assets-433845.data"; sourceTree = "<group>"; };
BEAB17581C9D062D009F8F58 /* repos-mdiep-MDPSplitView-releases-assets-433845.response */ = {isa = PBXFileReference; lastKnownFileType = file.bplist; path = "repos-mdiep-MDPSplitView-releases-assets-433845.response"; sourceTree = "<group>"; };
BEB0765C1C8A001C00ABD373 /* GitHubError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GitHubError.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -274,7 +280,9 @@
BE2B6A6B1C8B854F0080BFEB /* ClientTests.swift */,
BEB0765E1C8A019A00ABD373 /* GitHubErrorTests.swift */,
BE0F40A11C8909EB00E3B11A /* ReleaseTests.swift */,
BEA86F9C1C9F7E1E0049360B /* RepositoryTests.swift */,
BE1E036A1C9AD87F001296C2 /* ResponseTests.swift */,
BEA86F991C9F7C230049360B /* ServerTests.swift */,
BE88E8031C88C6B30034A112 /* Info.plist */,
);
path = Tests;
Expand Down Expand Up @@ -556,6 +564,8 @@
files = (
619081881C8A2DB7001BE2F8 /* Fixture.swift in Sources */,
BE2B6A6D1C8B854F0080BFEB /* ClientTests.swift in Sources */,
BEA86F9B1C9F7C230049360B /* ServerTests.swift in Sources */,
BEA86F9E1C9F7E1E0049360B /* RepositoryTests.swift in Sources */,
6190818B1C8A2DB7001BE2F8 /* (null) in Sources */,
619081891C8A2DB7001BE2F8 /* GitHubErrorTests.swift in Sources */,
BE1E036C1C9AD87F001296C2 /* ResponseTests.swift in Sources */,
Expand Down Expand Up @@ -584,9 +594,11 @@
buildActionMask = 2147483647;
files = (
BE1E036B1C9AD87F001296C2 /* ResponseTests.swift in Sources */,
BEA86F9D1C9F7E1E0049360B /* RepositoryTests.swift in Sources */,
BEB076601C8A019E00ABD373 /* GitHubErrorTests.swift in Sources */,
BE0F40A01C89098E00E3B11A /* Fixture.swift in Sources */,
BE2B6A6C1C8B854F0080BFEB /* ClientTests.swift in Sources */,
BEA86F9A1C9F7C230049360B /* ServerTests.swift in Sources */,
BE0F40A21C8909EB00E3B11A /* ReleaseTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
6 changes: 3 additions & 3 deletions Tentacle/Repository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public struct Repository: Hashable, CustomStringConvertible {
}

public var hashValue: Int {
return URL.hashValue
return description.lowercaseString.hashValue
}

public var description: String {
Expand All @@ -39,6 +39,6 @@ public struct Repository: Hashable, CustomStringConvertible {

public func ==(lhs: Repository, rhs: Repository) -> Bool {
return lhs.server == rhs.server
&& lhs.owner == rhs.owner
&& lhs.name == rhs.name
&& lhs.owner.caseInsensitiveCompare(rhs.owner) == .OrderedSame
&& lhs.name.caseInsensitiveCompare(rhs.name) == .OrderedSame
}
6 changes: 3 additions & 3 deletions Tentacle/Server.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public enum Server: Hashable, CustomStringConvertible {
}

public var hashValue: Int {
return endpoint.hashValue
return endpoint.lowercaseString.hashValue
}

public var description: String {
Expand All @@ -52,8 +52,8 @@ public func ==(lhs: Server, rhs: Server) -> Bool {
case (.DotCom, .DotCom):
return true

case let (.Enterprise(URL1), .Enterprise(URL2)):
return URL1 == URL2
case (.Enterprise, .Enterprise):
return lhs.endpoint.caseInsensitiveCompare(rhs.endpoint) == .OrderedSame

default:
return false
Expand Down
22 changes: 22 additions & 0 deletions Tests/RepositoryTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// RepositoryTests.swift
// Tentacle
//
// Created by Matt Diephouse on 3/20/16.
// Copyright © 2016 Matt Diephouse. All rights reserved.
//

import Tentacle
import XCTest

class RepositoryTests: XCTestCase {
func testEquality() {
let repo1 = Repository(owner: "mdiep", name: "Tentacle")
let repo2 = Repository(owner: "mdiep", name: "TENTACLE")
let repo3 = Repository(owner: "MDIEP", name: "Tentacle")
XCTAssertEqual(repo1, repo2)
XCTAssertEqual(repo1, repo3)
XCTAssertEqual(repo1.hashValue, repo2.hashValue)
XCTAssertEqual(repo1.hashValue, repo3.hashValue)
}
}
19 changes: 19 additions & 0 deletions Tests/ServerTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// ServerTests.swift
// Tentacle
//
// Created by Matt Diephouse on 3/20/16.
// Copyright © 2016 Matt Diephouse. All rights reserved.
//

import Tentacle
import XCTest

class ServerTests: XCTestCase {
func testEquality() {
let server1 = Server.Enterprise(url: NSURL(string: "https://example.com")!)
let server2 = Server.Enterprise(url: NSURL(string: "https://EXAMPLE.COM")!)
XCTAssertEqual(server1, server2)
XCTAssertEqual(server1.hashValue, server2.hashValue)
}
}