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

Adds support for SSH GitHub url for Swift Package Manager #128

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
9 changes: 6 additions & 3 deletions Sources/LicensePlistCore/Entity/SwiftPackage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,13 @@ extension SwiftPackage {
.replacingOccurrences(of: "http://", with: "")
.components(separatedBy: "/")

guard urlParts.count >= 3 else { return nil }

let name = urlParts.last?.deletingSuffix(".git") ?? ""
let owner = urlParts[urlParts.count - 2]
let owner: String
if urlParts.count >= 3 {
owner = urlParts[urlParts.count - 2]
} else {
owner = urlParts.first?.components(separatedBy: ":").last ?? ""
}

return GitHub(name: name,
nameSpecified: renames[name],
Expand Down
8 changes: 8 additions & 0 deletions Tests/LicensePlistTests/Entity/SwiftPackageManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ class SwiftPackageManagerTests: XCTestCase {
XCTAssertEqual(result, GitHub(name: "R.swift.Library", nameSpecified: nil, owner: "mac-cain13", version: nil))
}

func testConvertToGithubSSH() {
let package = SwiftPackage(package: "LicensePlist",
repositoryURL: "[email protected]:mono0926/LicensePlist.git",
state: SwiftPackage.State(branch: nil, revision: "3365947d725398694d6ed49f2e6622f05ca3fc0e", version: nil))
let result = package.toGitHub(renames: [:])
XCTAssertEqual(result, GitHub(name: "LicensePlist", nameSpecified: nil, owner: "mono0926", version: nil))
}

func testRename() {
let package = SwiftPackage(package: "Commander",
repositoryURL: "https://github.com/kylef/Commander.git",
Expand Down