Auto-update branch when merge conflicts (branch behind main); bump to 2.6
Build iOS App / Build .ipa and publish source (push) Successful in 22s
Build iOS App / Build .ipa and publish source (push) Successful in 22s
When a PR's head branch is behind main (or conflicts), Gitea's merge returns
409. Previously the app just showed an error. Now: on a 409 the app calls
POST /pulls/{index}/update (merges base into head), then retries the merge
once. Add APIError.mergeConflict for a clear message and map 409 in the
client. Bump to 2.6.
This commit is contained in:
@@ -93,6 +93,9 @@ struct GiteaClient {
|
||||
case 404:
|
||||
await LogStore.shared.log(.error, "\(method) \(path) → 404 not found")
|
||||
throw APIError.notFound
|
||||
case 409:
|
||||
await LogStore.shared.log(.warn, "\(method) \(path) → 409 conflict")
|
||||
throw APIError.mergeConflict
|
||||
default:
|
||||
let message = (try? Self.decoder.decode([String: String].self,
|
||||
from: data))?["message"]
|
||||
@@ -230,6 +233,14 @@ struct GiteaClient {
|
||||
method: "DELETE")
|
||||
}
|
||||
|
||||
/// Merge the base branch into the head branch (`POST /pulls/{index}/update`).
|
||||
/// When a PR is behind `main` (e.g. conflicts), the merge returns 409; this
|
||||
/// rebases/syncs the head onto the base so it can then be merged.
|
||||
func updateBranch(owner: String, repo: String, number: Int) async throws {
|
||||
_ = try await request("repos/\(owner)/\(repo)/pulls/\(number)/update",
|
||||
method: "POST")
|
||||
}
|
||||
|
||||
func setState(owner: String, repo: String, number: Int,
|
||||
state: String) async throws {
|
||||
struct Body: Encodable { let state: String }
|
||||
|
||||
Reference in New Issue
Block a user