diff --git a/Sources/ForgejoKit/Services/AdminService.swift b/Sources/ForgejoKit/Services/AdminService.swift index 91fb4f3..114b6c4 100644 --- a/Sources/ForgejoKit/Services/AdminService.swift +++ b/Sources/ForgejoKit/Services/AdminService.swift @@ -1,5 +1,29 @@ import Foundation +private struct CreateUserPayload: Codable { + let username: String + let password: String + let email: String + let loginName: String + let fullName: String? + let mustChangePassword: Bool + let sendNotify: Bool + let sourceId: Int + let visibility: String? + + enum CodingKeys: String, CodingKey { + case username + case password + case email + case loginName = "login_name" + case fullName = "full_name" + case mustChangePassword = "must_change_password" + case sendNotify = "send_notify" + case sourceId = "source_id" + case visibility + } +} + public final class AdminService: Sendable { private let client: ForgejoClient @@ -7,30 +31,6 @@ public final class AdminService: Sendable { self.client = client } - private struct CreateUserPayload: Codable { - let username: String - let password: String - let email: String - let loginName: String - let fullName: String? - let mustChangePassword: Bool - let sendNotify: Bool - let sourceId: Int - let visibility: String? - - enum CodingKeys: String, CodingKey { - case username - case password - case email - case loginName = "login_name" - case fullName = "full_name" - case mustChangePassword = "must_change_password" - case sendNotify = "send_notify" - case sourceId = "source_id" - case visibility - } - } - public func createUser( username: String, password: String, email: String, fullName: String? = nil, mustChangePassword: Bool = false, diff --git a/Sources/ForgejoKit/Services/ForgejoClient.swift b/Sources/ForgejoKit/Services/ForgejoClient.swift index 68338fe..eb480e7 100644 --- a/Sources/ForgejoKit/Services/ForgejoClient.swift +++ b/Sources/ForgejoKit/Services/ForgejoClient.swift @@ -137,7 +137,6 @@ public final class ForgejoClient: Sendable { } } - private static let tokenScopes = [ "read:user", "write:user", "read:repository", "write:repository", @@ -202,7 +201,6 @@ public final class ForgejoClient: Sendable { } } - func authenticatedRequest(url: URL, method: String = "GET", body: Data? = nil) -> URLRequest { var request = URLRequest(url: url) request.httpMethod = method @@ -283,7 +281,6 @@ public final class ForgejoClient: Sendable { } } - extension ForgejoClient { /// Characters allowed in a single URL path segment (`.urlPathAllowed` minus `/`). private static let pathSegmentAllowed: CharacterSet = { diff --git a/Sources/ForgejoKit/Services/PullRequestService.swift b/Sources/ForgejoKit/Services/PullRequestService.swift index 762f304..e376ebd 100644 --- a/Sources/ForgejoKit/Services/PullRequestService.swift +++ b/Sources/ForgejoKit/Services/PullRequestService.swift @@ -65,7 +65,6 @@ public final class PullRequestService: Sendable { } } - public func fetchPullRequests( owner: String, repo: String, state: String = "open", @@ -192,7 +191,6 @@ public final class PullRequestService: Sendable { return try await client.performRequestRawText(url: url) } - public func fetchComments( owner: String, repo: String, index: Int, ) async throws -> [IssueComment] { @@ -212,7 +210,6 @@ public final class PullRequestService: Sendable { try await issueService.editComment(owner: owner, repo: repo, commentId: commentId, body: body) } - public func fetchReviews( owner: String, repo: String, index: Int, ) async throws -> [PullRequestReview] { diff --git a/Sources/ForgejoKit/Services/RepositoryService.swift b/Sources/ForgejoKit/Services/RepositoryService.swift index 2a4851f..9551e56 100644 --- a/Sources/ForgejoKit/Services/RepositoryService.swift +++ b/Sources/ForgejoKit/Services/RepositoryService.swift @@ -1,6 +1,47 @@ import Foundation // swiftlint:disable file_length + +private struct CreateRepositoryPayload: Codable { + let name: String + let description: String? + let `private`: Bool + let autoInit: Bool + + enum CodingKeys: String, CodingKey { + case name + case description + case `private` + case autoInit = "auto_init" + } +} + +private struct CreateMilestonePayload: Codable { + let title: String + let description: String? + let dueOn: String? + + enum CodingKeys: String, CodingKey { + case title + case description + case dueOn = "due_on" + } +} + +private struct CreateFilePayload: Codable { + let content: String + let message: String + let branch: String? + let newBranch: String? + + enum CodingKeys: String, CodingKey { + case content + case message + case branch + case newBranch = "new_branch" + } +} + // swiftlint:disable:next type_body_length public final class RepositoryService: Sendable { private let client: ForgejoClient @@ -13,20 +54,6 @@ public final class RepositoryService: Sendable { let data: [Repository] } - private struct CreateRepositoryPayload: Codable { - let name: String - let description: String? - let `private`: Bool - let autoInit: Bool - - enum CodingKeys: String, CodingKey { - case name - case description - case `private` - case autoInit = "auto_init" - } - } - private struct EditRepositoryPayload: Codable { let archived: Bool? let description: String? @@ -39,36 +66,10 @@ public final class RepositoryService: Sendable { let description: String? } - private struct CreateMilestonePayload: Codable { - let title: String - let description: String? - let dueOn: String? - - enum CodingKeys: String, CodingKey { - case title - case description - case dueOn = "due_on" - } - } - private struct CollaboratorPayload: Codable { let permission: String } - private struct CreateFilePayload: Codable { - let content: String - let message: String - let branch: String? - let newBranch: String? - - enum CodingKeys: String, CodingKey { - case content - case message - case branch - case newBranch = "new_branch" - } - } - private struct CreateFileResponse: Codable { let content: FileContent } diff --git a/flake.lock b/flake.lock index 26355ca..2828dc2 100644 --- a/flake.lock +++ b/flake.lock @@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1772173633, - "narHash": "sha256-MOH58F4AIbCkh6qlQcwMycyk5SWvsqnS/TCfnqDlpj4=", + "lastModified": 1773110118, + "narHash": "sha256-mPAG8phMbCReKSiKAijjjd3v7uVcJOQ75gSjGJjt/Rk=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "c0f3d81a7ddbc2b1332be0d8481a672b4f6004d6", + "rev": "e607cb5360ff1234862ac9f8839522becb853bb9", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 97fdc5b..d7655c2 100644 --- a/flake.nix +++ b/flake.nix @@ -14,11 +14,10 @@ pkgs = nixpkgs.legacyPackages.${system}; in { - devShells.default = pkgs.mkShell { + devShells.default = pkgs.mkShellNoCC { packages = [ pkgs.just - pkgs.swift pkgs.swiftformat ] ++ pkgs.lib.optionals pkgs.stdenv.hostPlatform.isDarwin [