mirror of
https://github.com/zhigang1992/GitHawk.git
synced 2026-06-15 01:59:07 +08:00
* clean up title model * update title style * organize issue SC method * remove background colors from styled text in issues * collection view bg white * remove card inset and clean up snap superview code * clean up label design * thread is root and change base font size * remove borders on comment cells * adjust collapse design * adjust comment line spacing and make non-root body smaller * refactor detail view * viewer header background color * more buttons in reaction cell * vertical spacers working * design basically finished; * scroll to bottom accounts for inset * PR review background color white * fixup PR review comments * spacing on merge and review * readme background white * rename to just "spacer" * horizontal spacing * fix tests
65 lines
1.7 KiB
Swift
65 lines
1.7 KiB
Swift
//
|
|
// GithubClient+Merge.swift
|
|
// Freetime
|
|
//
|
|
// Created by Ryan Nystrom on 2/15/18.
|
|
// Copyright © 2018 Ryan Nystrom. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
import Squawk
|
|
import GitHubAPI
|
|
|
|
extension GithubClient {
|
|
|
|
func merge(
|
|
previous: IssueResult,
|
|
owner: String,
|
|
repo: String,
|
|
number: Int,
|
|
type: IssueMergeType,
|
|
error: @escaping () -> Void
|
|
) {
|
|
let newLabels = IssueLabelsModel(
|
|
status: IssueLabelStatusModel(
|
|
status: .merged,
|
|
pullRequest: previous.labels.status.pullRequest
|
|
),
|
|
locked: previous.labels.locked,
|
|
labels: previous.labels.labels
|
|
)
|
|
let newEvent = IssueStatusEventModel(
|
|
id: UUID().uuidString,
|
|
actor: userSession?.username ?? Constants.Strings.unknown,
|
|
commitHash: nil,
|
|
date: Date(),
|
|
status: .merged,
|
|
pullRequest: previous.pullRequest
|
|
)
|
|
let optimisticResult = previous.updated(
|
|
labels: newLabels,
|
|
timelinePages: previous.timelinePages(appending: [newEvent])
|
|
)
|
|
|
|
let mergeType: MergeType
|
|
switch type {
|
|
case .merge: mergeType = .merge
|
|
case .rebase: mergeType = .rebase
|
|
case .squash: mergeType = .squash
|
|
}
|
|
|
|
let cache = self.cache
|
|
|
|
client.send(V3MergePullRequestReqeust(owner: owner, repo: repo, number: number, type: mergeType)) { result in
|
|
switch result {
|
|
case .success:
|
|
cache.set(value: optimisticResult)
|
|
case .failure:
|
|
Squawk.showGenericError()
|
|
error()
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|