Skip to content

Commit

Permalink
Merge pull request #128 from wrutkowski/swift_package_manager_support…
Browse files Browse the repository at this point in the history
…_ssh_repo_url

Adds support for SSH GitHub url for Swift Package Manager
  • Loading branch information
mono0926 authored Feb 6, 2020
2 parents 53dba18 + 82f1a4a commit 1288516
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
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

0 comments on commit 1288516

Please sign in to comment.