Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Classes/Issues/Merge/IssueMergeModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import IGListKit
final class IssueMergeModel: ListDiffable {

let id: String
let state: MergeableState
let state: MergeStateStatus
let contexts: [IssueMergeContextModel]
let availableTypes: [IssueMergeType]

init(
id: String,
state: MergeableState,
state: MergeStateStatus,
contexts: [IssueMergeContextModel],
availableTypes: [IssueMergeType]
) {
Expand Down
34 changes: 28 additions & 6 deletions Classes/Issues/Merge/IssueMergeSectionController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,38 @@ ListBindingSectionControllerSelectionDelegate {

viewModels += object.contexts as [ListDiffable]

let mergeable = object.state == .mergeable
let title: String
let state: IssueMergeSummaryModel.State
let buttonEnabled: Bool
switch object.state {
case .clean, .hasHooks, .unstable:
title = NSLocalizedString("No conflicts with base branch", comment: "")
state = .success
buttonEnabled = true
case .behind:
title = NSLocalizedString("Head ref is out of date", comment: "")
state = .warning
buttonEnabled = false
case .blocked:
title = NSLocalizedString("Not authorized to merge", comment: "")
state = .failure
buttonEnabled = false
case .unknown, .__unknown(_):
title = NSLocalizedString("Merge status unknown", comment: "")
state = .pending
buttonEnabled = false
case .dirty:
title = NSLocalizedString("Merge conflicts found", comment: "")
state = .warning
buttonEnabled = false
}
viewModels.append(IssueMergeSummaryModel(
title: mergeable ?
NSLocalizedString("No conflicts with base branch", comment: "")
: NSLocalizedString("Merge conflicts found", comment: ""),
state: mergeable ? .success : .warning
title: title,
state: state
))

viewModels.append(IssueMergeButtonModel(
enabled: mergeable,
enabled: buttonEnabled,
type: preferredMergeType,
loading: loading
))
Expand Down
5 changes: 4 additions & 1 deletion Classes/Issues/Merge/IssueMergeSummaryCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ final class IssueMergeSummaryCell: CardCollectionViewCell, ListBindable {
case .failure:
imageViewBackground = Styles.Colors.Red.medium.color
iconName = "merge-x"
case .warning, .pending:
case .pending:
imageViewBackground = Styles.Colors.Yellow.medium.color
iconName = "primitive-dot"
case .warning:
imageViewBackground = Styles.Colors.Gray.medium.color
iconName = "merge-alert"
}
Expand Down
2 changes: 1 addition & 1 deletion Classes/Issues/PullRequest+IssueType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ extension IssueOrPullRequestQuery.Data.Repository.IssueOrPullRequest.AsPullReque

return IssueMergeModel(
id: commit.id,
state: mergeable,
state: mergeStateStatus,
contexts: contexts,
availableTypes: availableTypes
)
Expand Down
3 changes: 3 additions & 0 deletions Local Pods/GitHubAPI/GitHubAPI/ConfiguredNetworkers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public func ConfiguredNetworkers(
additionalHeaders["Authorization"] = header
}

// https://developer.github.com/v4/previews/#mergeinfopreview---more-detailed-information-about-a-pull-requests-merge-state
additionalHeaders["Accept"] = "application/vnd.github.merge-info-preview+json"

let config = URLSessionConfiguration.default
config.httpAdditionalHeaders = additionalHeaders
config.timeoutIntervalForRequest = 15
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "splash_branches@2x.png",
Expand Down
92 changes: 82 additions & 10 deletions gql/API.swift

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions gql/IssueOrPullRequest.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ query IssueOrPullRequest($owner: String!, $repo: String!, $number: Int!, $page_s
additions
deletions
mergeable
mergeStateStatus
}
}
}
Expand Down
Loading