Skip to content

Commit

Permalink
Merge pull request #153 from liamnichols/ln/github-repo-name-bug
Browse files Browse the repository at this point in the history
Installer cannot resolve gitPath using shortened GitHub repo name if repo has a period in its name
  • Loading branch information
yonaskolb authored Jan 5, 2020
2 parents 9010ebe + bd16976 commit c00436f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## Master

## 0.14.0

#### Fixed
- Fixed a bug that prevented the `Mintfile` from resolving a GitHub repository where the name contains a period [#153](https://github.com/yonaskolb/Mint/pull/153) @liamnichols

[Commits](https://github.com/yonaskolb/Mint/compare/0.13.0...0.14.0)

## 0.13.0

#### Added
Expand Down
4 changes: 2 additions & 2 deletions Sources/MintKit/PackageReference.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class PackageReference {
}

public var name: String {
return repo.components(separatedBy: "/").last!.components(separatedBy: ".").first!
return repo.components(separatedBy: "/").last!.replacingOccurrences(of: ".git", with: "")
}

public var gitPath: String {
Expand All @@ -53,7 +53,7 @@ public class PackageReference {
return repo
} else if repo.contains("github.com") {
return "https://\(repo).git"
} else if repo.contains(".") {
} else if repo.components(separatedBy: "/").first!.contains(".") {
return "https://\(repo)"
} else {
return "https://github.com/\(repo).git"
Expand Down
24 changes: 24 additions & 0 deletions Tests/MintTests/PackageTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,37 @@ class PackageTests: XCTestCase {
"https://mycustomdomain.com/package": "https://mycustomdomain.com/package",
"https://mycustomdomain.com/package.git": "https://mycustomdomain.com/package.git",
"git@github.com:yonaskolb/Mint.git": "git@github.com:yonaskolb/Mint.git",
"mac-cain13/R.swift": "https://github.com/mac-cain13/R.swift.git",
]

for (url, expected) in urls {
XCTAssertEqual(PackageReference(repo: url).gitPath, expected)
}
}

func testPackageNames() {

let urls: [String: String] = [
"yonaskolb/mint": "mint",
"github.com/yonaskolb/mint": "mint",
"https://github.com/yonaskolb/mint": "mint",
"https://github.com/yonaskolb/mint.git": "mint",
"mycustomdomain.com/package": "package",
"mycustomdomain.com/package.git": "package",
"https://mycustomdomain.com/package": "package",
"https://mycustomdomain.com/package.git": "package",
"git@github.com:yonaskolb/Mint.git": "Mint",
"mac-cain13/R.swift": "R.swift",
"github.com/mac-cain13/R.swift": "R.swift",
"https://github.com/mac-cain13/R.swift.git": "R.swift",
"git@github.com:mac-cain13/R.swift.git": "R.swift",
]

for (url, expected) in urls {
XCTAssertEqual(PackageReference(repo: url).name, expected)
}
}

func testPackageReferenceInfo() {

XCTAssertEqual(PackageReference(package: "yonaskolb/mint"), PackageReference(repo: "yonaskolb/mint"))
Expand Down

0 comments on commit c00436f

Please sign in to comment.