Skip to content

Commit

Permalink
Merge branch 'main' into fetch-license-swiftui
Browse files Browse the repository at this point in the history
  • Loading branch information
vtourraine authored Jan 18, 2024
2 parents 4101afa + c4842fb commit f75fbc1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Add `GitHubAPI` to get licenses from GitHub API
- Update `AcknowListViewController` and `AcknowListSwiftUIView` to get missing licenses from GitHub API, with new `canFetchLicenseFromGitHub` property to disable this behavior
- Fix open URL on macOS with SwiftUI


## 3.0.1 (24 November 2022)
Expand Down
4 changes: 3 additions & 1 deletion Sources/AcknowList/AcknowListSwiftUI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ public struct AcknowListRowSwiftUIView: View {
else if let repository = acknowledgement.repository,
canOpenRepository(for: repository) {
Button(action: {
#if os(iOS)
#if os(macOS)
NSWorkspace.shared.open(repository)
#elseif os(iOS)
UIApplication.shared.open(repository)
#endif
}) {
Expand Down
4 changes: 3 additions & 1 deletion Sources/AcknowList/GitHubAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ open class GitHubAPI {
let path = pathWithoutExtension(for: repository)
let url = "https://api.github.com/repos\(path)/license"
var request = URLRequest(url: URL(string: url)!)
request.allHTTPHeaderFields = ["Accept": "application/vnd.github.raw"]
request.allHTTPHeaderFields = [
"Accept": "application/vnd.github.raw",
"X-GitHub-Api-Version": "2022-11-28"]
return request
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/AcknowListTests/GitHubAPITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class GitHubAPITests: XCTestCase {
let request = GitHubAPI.getLicenseRequest(for: repoURL)

XCTAssertEqual(request.url?.absoluteString, "https://api.github.com/repos/vtourraine/AcknowList/license")
XCTAssertEqual(request.allHTTPHeaderFields, ["Accept": "application/vnd.github.raw"])
XCTAssertEqual(request.allHTTPHeaderFields, ["Accept": "application/vnd.github.raw", "X-GitHub-Api-Version": "2022-11-28"])
XCTAssertEqual(request.httpMethod, "GET")
}
}

0 comments on commit f75fbc1

Please sign in to comment.