diff --git a/Classes/Repository/GQL+RepositoryIssueSummaryType.swift b/Classes/Repository/GQL+RepositoryIssueSummaryType.swift index 28a20f1cb..24050d1c7 100644 --- a/Classes/Repository/GQL+RepositoryIssueSummaryType.swift +++ b/Classes/Repository/GQL+RepositoryIssueSummaryType.swift @@ -8,53 +8,6 @@ import Foundation -extension RepoIssuePagesQuery.Data.Repository.Issue.Node: RepositoryIssueSummaryType { - - var labelableFields: LabelableFields { - return fragments.labelableFields - } - - var repoEventFields: RepoEventFields { - return fragments.repoEventFields - } - - var pullRequest: Bool { - return false - } - - var status: IssueStatus { - switch state { - case .closed: return .closed - case .open, .__unknown: return .open - } - } - -} - -extension RepoPullRequestPagesQuery.Data.Repository.PullRequest.Node: RepositoryIssueSummaryType { - - var labelableFields: LabelableFields { - return fragments.labelableFields - } - - var repoEventFields: RepoEventFields { - return fragments.repoEventFields - } - - var pullRequest: Bool { - return true - } - - var status: IssueStatus { - switch state { - case .closed: return .closed - case .merged: return .merged - case .open, .__unknown: return .open - } - } - -} - extension RepoSearchPagesQuery.Data.Search.Node.AsIssue: RepositoryIssueSummaryType { var labelableFields: LabelableFields { @@ -76,6 +29,10 @@ extension RepoSearchPagesQuery.Data.Search.Node.AsIssue: RepositoryIssueSummaryT } } + var ciStatus: RepositoryIssueCIStatus? { + return nil + } + } extension RepoSearchPagesQuery.Data.Search.Node.AsPullRequest: RepositoryIssueSummaryType { @@ -100,4 +57,11 @@ extension RepoSearchPagesQuery.Data.Search.Node.AsPullRequest: RepositoryIssueSu } } + var ciStatus: RepositoryIssueCIStatus? { + guard let node = commits.nodes?.first, + let status = node?.commit.status + else { return nil } + return RepositoryIssueCIStatus(rawValue: status.state.rawValue) + } + } diff --git a/Classes/Repository/RepositoryClient.swift b/Classes/Repository/RepositoryClient.swift index 8c8a85a72..27cb46d59 100644 --- a/Classes/Repository/RepositoryClient.swift +++ b/Classes/Repository/RepositoryClient.swift @@ -17,36 +17,6 @@ protocol RepositoryQuery { func nextPageToken(from data: GraphQLSelectionSet) -> String? } -extension RepoIssuePagesQuery: RepositoryQuery { - - func summaryTypes(from data: GraphQLSelectionSet) -> [RepositoryIssueSummaryType] { - guard let issues = data as? Data else { return [] } - return issues.repository?.issues.nodes?.compactMap { $0 } ?? [] - } - - func nextPageToken(from data: GraphQLSelectionSet) -> String? { - guard let issues = data as? Data else { return nil } - guard let pageInfo = issues.repository?.issues.pageInfo, pageInfo.hasNextPage else { return nil } - return pageInfo.endCursor - } - -} - -extension RepoPullRequestPagesQuery: RepositoryQuery { - - func summaryTypes(from data: GraphQLSelectionSet) -> [RepositoryIssueSummaryType] { - guard let prs = data as? RepoPullRequestPagesQuery.Data else { return [] } - return prs.repository?.pullRequests.nodes?.compactMap { $0 } ?? [] - } - - func nextPageToken(from data: GraphQLSelectionSet) -> String? { - guard let prs = data as? RepoPullRequestPagesQuery.Data else { return nil } - guard let pageInfo = prs.repository?.pullRequests.pageInfo, pageInfo.hasNextPage else { return nil } - return pageInfo.endCursor - } - -} - extension RepoSearchPagesQuery: RepositoryQuery { func summaryTypes(from data: GraphQLSelectionSet) -> [RepositoryIssueSummaryType] { @@ -69,12 +39,34 @@ func createSummaryModel( ) -> RepositoryIssueSummaryModel? { guard let date = node.repoEventFields.createdAt.githubDate else { return nil } - let title = StyledTextBuilder(styledText: StyledText( + let builder = StyledTextBuilder(styledText: StyledText( text: node.title, - style: Styles.Text.body.with(foreground: Styles.Colors.Gray.dark.color) - )).build() +// style: Styles.Text.body.with(foreground: Styles.Colors.Gray.medium.color) + style: Styles.Text.body + )) + if let ciStatus = node.ciStatus { + let iconName: String + let color: UIColor + switch ciStatus { + case .pending: + iconName = "primitive-dot" + color = Styles.Colors.Yellow.medium.color + case .failure: + iconName = "x-small" + color = Styles.Colors.Red.medium.color + case .success: + iconName = "check-small" + color = Styles.Colors.Green.medium.color + } + if let icon = UIImage(named: iconName)?.withRenderingMode(.alwaysTemplate) { + builder.save() + .add(text: "\u{00A0}") + .add(image: icon, attributes: [.foregroundColor: color]) + .restore() + } + } let string = StyledTextRenderer( - string: title, + string: builder.build(), contentSizeCategory: contentSizeCategory, inset: RepositorySummaryCell.titleInset ).warm(width: containerWidth) @@ -87,7 +79,8 @@ func createSummaryModel( author: node.repoEventFields.author?.login ?? Constants.Strings.unknown, status: node.status, pullRequest: node.pullRequest, - labels: node.labelableFields.issueLabelModels + labels: node.labelableFields.issueLabelModels, + ciStatus: node.ciStatus ) } @@ -98,11 +91,13 @@ func createSummaryModel( containerWidth: CGFloat ) -> (models: [RepositoryIssueSummaryModel], nextPage: String?) { let nextPage = query.nextPageToken(from: data) - let models: [RepositoryIssueSummaryModel] = query.summaryTypes(from: data).compactMap { (node: RepositoryIssueSummaryType) in - return createSummaryModel(node, contentSizeCategory: contentSizeCategory, containerWidth: containerWidth) - }.sorted(by: { - $0.created > $1.created - }) + let models = query.summaryTypes(from: data).compactMap { node in + return createSummaryModel( + node, + contentSizeCategory: contentSizeCategory, + containerWidth: containerWidth + ) + }.sorted {$0.created > $1.created } return (models, nextPage) } @@ -155,30 +150,6 @@ final class RepositoryClient { }) } - func loadIssues( - nextPage: String? = nil, - containerWidth: CGFloat, - completion: @escaping (Result) -> Void - ) { - loadPage( - query: RepoIssuePagesQuery(owner: owner, name: name, after: nextPage, page_size: 30), - containerWidth: containerWidth, - completion: completion - ) - } - - func loadPullRequests( - nextPage: String? = nil, - containerWidth: CGFloat, - completion: @escaping (Result) -> Void - ) { - loadPage( - query: RepoPullRequestPagesQuery(owner: owner, name: name, after: nextPage, page_size: 30), - containerWidth: containerWidth, - completion: completion - ) - } - func searchIssues( query: String, nextPage: String? = nil, diff --git a/Classes/Repository/RepositoryIssueSummaryModel.swift b/Classes/Repository/RepositoryIssueSummaryModel.swift index e77158326..a38a775a9 100644 --- a/Classes/Repository/RepositoryIssueSummaryModel.swift +++ b/Classes/Repository/RepositoryIssueSummaryModel.swift @@ -20,6 +20,7 @@ class RepositoryIssueSummaryModel: ListDiffable { let status: IssueStatus let pullRequest: Bool let labels: [RepositoryLabel] + let ciStatus: RepositoryIssueCIStatus? // quicker comparison for diffing rather than scanning the labels array let labelSummary: String @@ -32,7 +33,8 @@ class RepositoryIssueSummaryModel: ListDiffable { author: String, status: IssueStatus, pullRequest: Bool, - labels: [RepositoryLabel] + labels: [RepositoryLabel], + ciStatus: RepositoryIssueCIStatus? ) { self.id = id self.title = title @@ -43,6 +45,7 @@ class RepositoryIssueSummaryModel: ListDiffable { self.pullRequest = pullRequest self.labels = labels self.labelSummary = labels.reduce("", { $0 + $1.name }) + self.ciStatus = ciStatus } // MARK: ListDiffable @@ -62,5 +65,6 @@ class RepositoryIssueSummaryModel: ListDiffable { && created == object.created && title.string == object.title.string && labelSummary == object.labelSummary + && ciStatus == object.ciStatus } } diff --git a/Classes/Repository/RepositoryIssueSummaryType.swift b/Classes/Repository/RepositoryIssueSummaryType.swift index 3cc9391dc..52575438a 100644 --- a/Classes/Repository/RepositoryIssueSummaryType.swift +++ b/Classes/Repository/RepositoryIssueSummaryType.swift @@ -8,6 +8,12 @@ import IGListKit +enum RepositoryIssueCIStatus: String { + case pending = "PENDING" + case failure = "FAILURE" + case success = "SUCCESS" +} + protocol RepositoryIssueSummaryType { var number: Int { get } @@ -17,5 +23,6 @@ protocol RepositoryIssueSummaryType { var labelableFields: LabelableFields { get } var pullRequest: Bool { get } var title: String { get } + var ciStatus: RepositoryIssueCIStatus? { get } } diff --git a/Podfile.lock b/Podfile.lock index 04b7744df..b4009c0c7 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -169,7 +169,7 @@ CHECKOUT OPTIONS: :commit: 88d671bbe86e3c18d54e094fac97df12a3054d53 :git: https://github.com/GitHawkApp/Squawk.git StyledTextKit: - :commit: d15f77a32203daafd71e14e6f5911528e932aca5 + :commit: 8583c80e742f886e541c5ec500b7be6f5e7a233f :git: https://github.com/GitHawkApp/StyledTextKit.git SPEC CHECKSUMS: diff --git a/Pods/Manifest.lock b/Pods/Manifest.lock index 04b7744df..b4009c0c7 100644 --- a/Pods/Manifest.lock +++ b/Pods/Manifest.lock @@ -169,7 +169,7 @@ CHECKOUT OPTIONS: :commit: 88d671bbe86e3c18d54e094fac97df12a3054d53 :git: https://github.com/GitHawkApp/Squawk.git StyledTextKit: - :commit: d15f77a32203daafd71e14e6f5911528e932aca5 + :commit: 8583c80e742f886e541c5ec500b7be6f5e7a233f :git: https://github.com/GitHawkApp/StyledTextKit.git SPEC CHECKSUMS: diff --git a/Pods/StyledTextKit/Source/StyledText.swift b/Pods/StyledTextKit/Source/StyledText.swift index ab56c237c..983217189 100644 --- a/Pods/StyledTextKit/Source/StyledText.swift +++ b/Pods/StyledTextKit/Source/StyledText.swift @@ -11,9 +11,21 @@ import UIKit public class StyledText: Hashable, Equatable { + public struct ImageFitOptions: OptionSet { + public let rawValue: Int + + public init(rawValue: Int) { + self.rawValue = rawValue + } + + public static let fit = ImageFitOptions(rawValue: 1 << 0) + public static let center = ImageFitOptions(rawValue: 2 << 0) + } + public enum Storage: Hashable, Equatable { case text(String) case attributedText(NSAttributedString) + case image(UIImage, [ImageFitOptions]) // MARK: Hashable @@ -21,6 +33,7 @@ public class StyledText: Hashable, Equatable { switch self { case .text(let text): return text.hashValue case .attributedText(let text): return text.hashValue + case .image(let image, _): return image.hashValue } } @@ -31,13 +44,19 @@ public class StyledText: Hashable, Equatable { case .text(let lhsText): switch rhs { case .text(let rhsText): return lhsText == rhsText - case .attributedText: return false + case .attributedText, .image: return false } case .attributedText(let lhsText): switch rhs { - case .text: return false + case .text, .image: return false case .attributedText(let rhsText): return lhsText == rhsText } + case .image(let lhsImage, let lhsOptions): + switch rhs { + case .text, .attributedText: return false + case .image(let rhsImage, let rhsOptions): + return lhsImage == rhsImage && lhsOptions == rhsOptions + } } } @@ -59,14 +78,17 @@ public class StyledText: Hashable, Equatable { switch storage { case .text(let text): return text case .attributedText(let text): return text.string + case .image: return "" } } internal func render(contentSizeCategory: UIContentSizeCategory) -> NSAttributedString { var attributes = style.attributes - attributes[.font] = style.font(contentSizeCategory: contentSizeCategory) + let font = style.font(contentSizeCategory: contentSizeCategory) + attributes[.font] = font switch storage { - case .text(let text): return NSAttributedString(string: text, attributes: attributes) + case .text(let text): + return NSAttributedString(string: text, attributes: attributes) case .attributedText(let text): guard text.length > 0 else { return text } let mutable = text.mutableCopy() as? NSMutableAttributedString ?? NSMutableAttributedString() @@ -78,6 +100,37 @@ public class StyledText: Hashable, Equatable { } } return mutable + case .image(let image, let options): + let attachment = NSTextAttachment() + attachment.image = image + + var bounds = attachment.bounds + let size = image.size + if options.contains(.fit) { + let ratio = size.width / size.height + let fontHeight = min(ceil(font.pointSize), size.height) + bounds.size.width = ratio * fontHeight + bounds.size.height = fontHeight + } else { + bounds.size = size + } + + if options.contains(.center) { + bounds.origin.y = round((font.capHeight - bounds.height) / 2) + } + attachment.bounds = bounds + + // non-breaking space so the color hack doesn't wrap + let attributedString = NSMutableAttributedString(string: "\u{00A0}") + attributedString.append(NSAttributedString(attachment: attachment)) + // replace attributes to 0 size font so no actual space taken + attributes[.font] = UIFont.systemFont(ofSize: 0) + // override all attributes so color actually tints image + attributedString.addAttributes( + attributes, + range: NSRange(location: 0, length: attributedString.length) + ) + return attributedString } } diff --git a/Pods/StyledTextKit/Source/StyledTextBuilder.swift b/Pods/StyledTextKit/Source/StyledTextBuilder.swift index 385659313..7acd116e5 100644 --- a/Pods/StyledTextKit/Source/StyledTextBuilder.swift +++ b/Pods/StyledTextKit/Source/StyledTextBuilder.swift @@ -132,28 +132,12 @@ public final class StyledTextBuilder: Hashable, Equatable { } @discardableResult - public func add(image: UIImage) -> StyledTextBuilder { - guard let tipStyle = savedStyles.last else { return self } - - let font = tipStyle.font(contentSizeCategory: .medium) - let imageSize = CGSize(width: font.pointSize, height: font.pointSize) - let mid = font.descender + font.capHeight - let bounds = CGRect(x: 0, - y: round(font.descender - imageSize.height / 2 + mid + 1), - width: imageSize.width, - height: imageSize.height) - - let textAttachment = NSTextAttachment() - textAttachment.image = image - textAttachment.bounds = bounds - - let textAttributes: [NSAttributedStringKey: Any] = [ - .font: font, - .kern: 1.0 - ] - - let attributedString = NSAttributedString(attachment: textAttachment) - return add(storage: .attributedText(attributedString), traits: nil, attributes: textAttributes) + public func add( + image: UIImage, + options: [StyledText.ImageFitOptions] = [.fit, .center], + attributes: [NSAttributedStringKey: Any]? = nil + ) -> StyledTextBuilder { + return add(storage: .image(image, options), attributes: attributes) } @discardableResult diff --git a/Pods/StyledTextKit/Source/StyledTextRenderer.swift b/Pods/StyledTextKit/Source/StyledTextRenderer.swift index 910220add..b976ab69a 100644 --- a/Pods/StyledTextKit/Source/StyledTextRenderer.swift +++ b/Pods/StyledTextKit/Source/StyledTextRenderer.swift @@ -22,7 +22,22 @@ public final class StyledTextRenderer { private var lock = os_unfair_lock_s() private var contentSizeCategory: UIContentSizeCategory - public init( + internal static let globalSizeCache = LRUCache( + maxSize: 1000, // CGSize cache size always 1, treat as item count + compaction: .default, + clearOnWarning: true + ) + + internal static let globalBitmapCache = LRUCache( + maxSize: 1024 * 1024 * 20, // 20mb + compaction: .default, + clearOnWarning: true + ) + + internal var sizeCache: LRUCache + internal var bitmapCache: LRUCache + + public convenience init( string: StyledTextString, contentSizeCategory: UIContentSizeCategory, inset: UIEdgeInsets = .zero, @@ -31,11 +46,37 @@ public final class StyledTextRenderer { scale: CGFloat = StyledTextScreenScale, maximumNumberOfLines: Int = 0 ) { + self.init( + string: string, + contentSizeCategory: contentSizeCategory, + inset: inset, + backgroundColor: backgroundColor, + layoutManager: layoutManager, + scale: scale, + maximumNumberOfLines: maximumNumberOfLines, + sizeCache: nil, + bitmapCache: nil + ) + } + + internal init( + string: StyledTextString, + contentSizeCategory: UIContentSizeCategory, + inset: UIEdgeInsets, + backgroundColor: UIColor?, + layoutManager: NSLayoutManager, + scale: CGFloat, + maximumNumberOfLines: Int, + sizeCache: LRUCache?, + bitmapCache: LRUCache? + ) { self.string = string self.contentSizeCategory = contentSizeCategory self.inset = inset self.backgroundColor = backgroundColor self.scale = scale + self.sizeCache = sizeCache ?? StyledTextRenderer.globalSizeCache + self.bitmapCache = bitmapCache ?? StyledTextRenderer.globalBitmapCache textContainer = NSTextContainer() textContainer.exclusionPaths = [] @@ -61,23 +102,16 @@ public final class StyledTextRenderer { return storage } - private static let globalSizeCache = LRUCache( - maxSize: 1000, // CGSize cache size always 1, treat as item count - compaction: .default, - clearOnWarning: true - ) - // not thread safe private func _size(_ key: StyledTextRenderCacheKey) -> CGSize { - let cache = StyledTextRenderer.globalSizeCache - if let cached = cache[key] { + if let cached = sizeCache[key] { // always update the container to requested size textContainer.size = cached return cached } let insetWidth = max(key.width - inset.left - inset.right, 0) let size = layoutManager.size(textContainer: textContainer, width: insetWidth, scale: scale) - cache[key] = size + sizeCache[key] = size return size } @@ -91,12 +125,6 @@ public final class StyledTextRenderer { return size(in: width).resized(inset: inset) } - private static let globalBitmapCache = LRUCache( - maxSize: 1024 * 1024 * 20, // 20mb - compaction: .default, - clearOnWarning: true - ) - public func cachedRender(for width: CGFloat) -> (image: CGImage?, size: CGSize?) { os_unfair_lock_lock(&lock) defer { os_unfair_lock_unlock(&lock) } @@ -107,7 +135,7 @@ public final class StyledTextRenderer { backgroundColor: backgroundColor, maximumNumberOfLines: 0 ) - return (StyledTextRenderer.globalBitmapCache[key], StyledTextRenderer.globalSizeCache[key]) + return (bitmapCache[key], sizeCache[key]) } public func render(for width: CGFloat) -> (image: CGImage?, size: CGSize) { @@ -116,7 +144,7 @@ public final class StyledTextRenderer { let key = StyledTextRenderCacheKey(width: width, attributedText: storage, backgroundColor: backgroundColor, maximumNumberOfLines: textContainer.maximumNumberOfLines) let size = _size(key) - let cache = StyledTextRenderer.globalBitmapCache + let cache = bitmapCache if let cached = cache[key] { return (cached, size) } diff --git a/Settings.bundle/com.mono0926.LicensePlist.plist b/Settings.bundle/com.mono0926.LicensePlist.plist index 7ffa5b3e5..2d55d7354 100644 --- a/Settings.bundle/com.mono0926.LicensePlist.plist +++ b/Settings.bundle/com.mono0926.LicensePlist.plist @@ -48,7 +48,7 @@ File com.mono0926.LicensePlist/ContextMenu Title - ContextMenu (0.2.0) + ContextMenu (0.3.1) Type PSChildPaneSpecifier diff --git a/gql/API.swift b/gql/API.swift index 55adaf6f3..80f2d914d 100644 --- a/gql/API.swift +++ b/gql/API.swift @@ -14647,7 +14647,7 @@ public final class RepoFilesQuery: GraphQLQuery { public final class RepoSearchPagesQuery: GraphQLQuery { public static let operationString = - "query RepoSearchPages($query: String!, $after: String, $page_size: Int!) {\n search(query: $query, type: ISSUE, after: $after, first: $page_size) {\n __typename\n nodes {\n __typename\n ... on Issue {\n ...repoEventFields\n ...nodeFields\n ...labelableFields\n title\n number\n issueState: state\n }\n ... on PullRequest {\n ...repoEventFields\n ...nodeFields\n ...labelableFields\n title\n number\n pullRequestState: state\n }\n }\n pageInfo {\n __typename\n hasNextPage\n endCursor\n }\n }\n}" + "query RepoSearchPages($query: String!, $after: String, $page_size: Int!) {\n search(query: $query, type: ISSUE, after: $after, first: $page_size) {\n __typename\n nodes {\n __typename\n ... on Issue {\n ...repoEventFields\n ...nodeFields\n ...labelableFields\n title\n number\n issueState: state\n }\n ... on PullRequest {\n ...repoEventFields\n ...nodeFields\n ...labelableFields\n title\n number\n pullRequestState: state\n commits(last: 1) {\n __typename\n nodes {\n __typename\n commit {\n __typename\n status {\n __typename\n state\n }\n }\n }\n }\n }\n }\n pageInfo {\n __typename\n hasNextPage\n endCursor\n }\n }\n}" public static var requestString: String { return operationString.appending(RepoEventFields.fragmentString).appending(NodeFields.fragmentString).appending(LabelableFields.fragmentString) } @@ -14778,8 +14778,8 @@ public final class RepoSearchPagesQuery: GraphQLQuery { return Node(snapshot: ["__typename": "Issue", "createdAt": createdAt, "author": author.flatMap { (value: AsIssue.Author) -> Snapshot in value.snapshot }, "id": id, "labels": labels.flatMap { (value: AsIssue.Label) -> Snapshot in value.snapshot }, "title": title, "number": number, "issueState": issueState]) } - public static func makePullRequest(createdAt: String, author: AsPullRequest.Author? = nil, id: GraphQLID, labels: AsPullRequest.Label? = nil, title: String, number: Int, pullRequestState: PullRequestState) -> Node { - return Node(snapshot: ["__typename": "PullRequest", "createdAt": createdAt, "author": author.flatMap { (value: AsPullRequest.Author) -> Snapshot in value.snapshot }, "id": id, "labels": labels.flatMap { (value: AsPullRequest.Label) -> Snapshot in value.snapshot }, "title": title, "number": number, "pullRequestState": pullRequestState]) + public static func makePullRequest(createdAt: String, author: AsPullRequest.Author? = nil, id: GraphQLID, labels: AsPullRequest.Label? = nil, title: String, number: Int, pullRequestState: PullRequestState, commits: AsPullRequest.Commit) -> Node { + return Node(snapshot: ["__typename": "PullRequest", "createdAt": createdAt, "author": author.flatMap { (value: AsPullRequest.Author) -> Snapshot in value.snapshot }, "id": id, "labels": labels.flatMap { (value: AsPullRequest.Label) -> Snapshot in value.snapshot }, "title": title, "number": number, "pullRequestState": pullRequestState, "commits": commits.snapshot]) } public var __typename: String { @@ -15108,6 +15108,7 @@ public final class RepoSearchPagesQuery: GraphQLQuery { GraphQLField("title", type: .nonNull(.scalar(String.self))), GraphQLField("number", type: .nonNull(.scalar(Int.self))), GraphQLField("state", alias: "pullRequestState", type: .nonNull(.scalar(PullRequestState.self))), + GraphQLField("commits", arguments: ["last": 1], type: .nonNull(.object(Commit.selections))), ] public var snapshot: Snapshot @@ -15116,8 +15117,8 @@ public final class RepoSearchPagesQuery: GraphQLQuery { self.snapshot = snapshot } - public init(createdAt: String, author: Author? = nil, id: GraphQLID, labels: Label? = nil, title: String, number: Int, pullRequestState: PullRequestState) { - self.init(snapshot: ["__typename": "PullRequest", "createdAt": createdAt, "author": author.flatMap { (value: Author) -> Snapshot in value.snapshot }, "id": id, "labels": labels.flatMap { (value: Label) -> Snapshot in value.snapshot }, "title": title, "number": number, "pullRequestState": pullRequestState]) + public init(createdAt: String, author: Author? = nil, id: GraphQLID, labels: Label? = nil, title: String, number: Int, pullRequestState: PullRequestState, commits: Commit) { + self.init(snapshot: ["__typename": "PullRequest", "createdAt": createdAt, "author": author.flatMap { (value: Author) -> Snapshot in value.snapshot }, "id": id, "labels": labels.flatMap { (value: Label) -> Snapshot in value.snapshot }, "title": title, "number": number, "pullRequestState": pullRequestState, "commits": commits.snapshot]) } public var __typename: String { @@ -15199,6 +15200,16 @@ public final class RepoSearchPagesQuery: GraphQLQuery { } } + /// A list of commits present in this pull request's head branch not present in the base branch. + public var commits: Commit { + get { + return Commit(snapshot: snapshot["commits"]! as! Snapshot) + } + set { + snapshot.updateValue(newValue.snapshot, forKey: "commits") + } + } + public var fragments: Fragments { get { return Fragments(snapshot: snapshot) @@ -15371,154 +15382,168 @@ public final class RepoSearchPagesQuery: GraphQLQuery { } } } - } - } - public struct PageInfo: GraphQLSelectionSet { - public static let possibleTypes = ["PageInfo"] + public struct Commit: GraphQLSelectionSet { + public static let possibleTypes = ["PullRequestCommitConnection"] - public static let selections: [GraphQLSelection] = [ - GraphQLField("__typename", type: .nonNull(.scalar(String.self))), - GraphQLField("hasNextPage", type: .nonNull(.scalar(Bool.self))), - GraphQLField("endCursor", type: .scalar(String.self)), - ] + public static let selections: [GraphQLSelection] = [ + GraphQLField("__typename", type: .nonNull(.scalar(String.self))), + GraphQLField("nodes", type: .list(.object(Node.selections))), + ] - public var snapshot: Snapshot + public var snapshot: Snapshot - public init(snapshot: Snapshot) { - self.snapshot = snapshot - } + public init(snapshot: Snapshot) { + self.snapshot = snapshot + } - public init(hasNextPage: Bool, endCursor: String? = nil) { - self.init(snapshot: ["__typename": "PageInfo", "hasNextPage": hasNextPage, "endCursor": endCursor]) - } + public init(nodes: [Node?]? = nil) { + self.init(snapshot: ["__typename": "PullRequestCommitConnection", "nodes": nodes.flatMap { (value: [Node?]) -> [Snapshot?] in value.map { (value: Node?) -> Snapshot? in value.flatMap { (value: Node) -> Snapshot in value.snapshot } } }]) + } - public var __typename: String { - get { - return snapshot["__typename"]! as! String - } - set { - snapshot.updateValue(newValue, forKey: "__typename") - } - } + public var __typename: String { + get { + return snapshot["__typename"]! as! String + } + set { + snapshot.updateValue(newValue, forKey: "__typename") + } + } - /// When paginating forwards, are there more items? - public var hasNextPage: Bool { - get { - return snapshot["hasNextPage"]! as! Bool - } - set { - snapshot.updateValue(newValue, forKey: "hasNextPage") - } - } + /// A list of nodes. + public var nodes: [Node?]? { + get { + return (snapshot["nodes"] as? [Snapshot?]).flatMap { (value: [Snapshot?]) -> [Node?] in value.map { (value: Snapshot?) -> Node? in value.flatMap { (value: Snapshot) -> Node in Node(snapshot: value) } } } + } + set { + snapshot.updateValue(newValue.flatMap { (value: [Node?]) -> [Snapshot?] in value.map { (value: Node?) -> Snapshot? in value.flatMap { (value: Node) -> Snapshot in value.snapshot } } }, forKey: "nodes") + } + } - /// When paginating forwards, the cursor to continue. - public var endCursor: String? { - get { - return snapshot["endCursor"] as? String - } - set { - snapshot.updateValue(newValue, forKey: "endCursor") - } - } - } - } - } -} + public struct Node: GraphQLSelectionSet { + public static let possibleTypes = ["PullRequestCommit"] -public final class RepoIssuePagesQuery: GraphQLQuery { - public static let operationString = - "query RepoIssuePages($owner: String!, $name: String!, $after: String, $page_size: Int!) {\n repository(owner: $owner, name: $name) {\n __typename\n issues(first: $page_size, orderBy: {field: CREATED_AT, direction: DESC}, states: [OPEN, CLOSED], after: $after) {\n __typename\n nodes {\n __typename\n ...repoEventFields\n ...nodeFields\n ...labelableFields\n title\n number\n state\n }\n pageInfo {\n __typename\n hasNextPage\n endCursor\n }\n }\n }\n}" + public static let selections: [GraphQLSelection] = [ + GraphQLField("__typename", type: .nonNull(.scalar(String.self))), + GraphQLField("commit", type: .nonNull(.object(Commit.selections))), + ] - public static var requestString: String { return operationString.appending(RepoEventFields.fragmentString).appending(NodeFields.fragmentString).appending(LabelableFields.fragmentString) } + public var snapshot: Snapshot - public var owner: String - public var name: String - public var after: String? - public var page_size: Int + public init(snapshot: Snapshot) { + self.snapshot = snapshot + } - public init(owner: String, name: String, after: String? = nil, page_size: Int) { - self.owner = owner - self.name = name - self.after = after - self.page_size = page_size - } + public init(commit: Commit) { + self.init(snapshot: ["__typename": "PullRequestCommit", "commit": commit.snapshot]) + } - public var variables: GraphQLMap? { - return ["owner": owner, "name": name, "after": after, "page_size": page_size] - } + public var __typename: String { + get { + return snapshot["__typename"]! as! String + } + set { + snapshot.updateValue(newValue, forKey: "__typename") + } + } - public struct Data: GraphQLSelectionSet { - public static let possibleTypes = ["Query"] + /// The Git commit object + public var commit: Commit { + get { + return Commit(snapshot: snapshot["commit"]! as! Snapshot) + } + set { + snapshot.updateValue(newValue.snapshot, forKey: "commit") + } + } - public static let selections: [GraphQLSelection] = [ - GraphQLField("repository", arguments: ["owner": GraphQLVariable("owner"), "name": GraphQLVariable("name")], type: .object(Repository.selections)), - ] + public struct Commit: GraphQLSelectionSet { + public static let possibleTypes = ["Commit"] - public var snapshot: Snapshot + public static let selections: [GraphQLSelection] = [ + GraphQLField("__typename", type: .nonNull(.scalar(String.self))), + GraphQLField("status", type: .object(Status.selections)), + ] - public init(snapshot: Snapshot) { - self.snapshot = snapshot - } + public var snapshot: Snapshot - public init(repository: Repository? = nil) { - self.init(snapshot: ["__typename": "Query", "repository": repository.flatMap { (value: Repository) -> Snapshot in value.snapshot }]) - } + public init(snapshot: Snapshot) { + self.snapshot = snapshot + } - /// Lookup a given repository by the owner and repository name. - public var repository: Repository? { - get { - return (snapshot["repository"] as? Snapshot).flatMap { Repository(snapshot: $0) } - } - set { - snapshot.updateValue(newValue?.snapshot, forKey: "repository") - } - } + public init(status: Status? = nil) { + self.init(snapshot: ["__typename": "Commit", "status": status.flatMap { (value: Status) -> Snapshot in value.snapshot }]) + } - public struct Repository: GraphQLSelectionSet { - public static let possibleTypes = ["Repository"] + public var __typename: String { + get { + return snapshot["__typename"]! as! String + } + set { + snapshot.updateValue(newValue, forKey: "__typename") + } + } - public static let selections: [GraphQLSelection] = [ - GraphQLField("__typename", type: .nonNull(.scalar(String.self))), - GraphQLField("issues", arguments: ["first": GraphQLVariable("page_size"), "orderBy": ["field": "CREATED_AT", "direction": "DESC"], "states": ["OPEN", "CLOSED"], "after": GraphQLVariable("after")], type: .nonNull(.object(Issue.selections))), - ] + /// Status information for this commit + public var status: Status? { + get { + return (snapshot["status"] as? Snapshot).flatMap { Status(snapshot: $0) } + } + set { + snapshot.updateValue(newValue?.snapshot, forKey: "status") + } + } - public var snapshot: Snapshot + public struct Status: GraphQLSelectionSet { + public static let possibleTypes = ["Status"] - public init(snapshot: Snapshot) { - self.snapshot = snapshot - } + public static let selections: [GraphQLSelection] = [ + GraphQLField("__typename", type: .nonNull(.scalar(String.self))), + GraphQLField("state", type: .nonNull(.scalar(StatusState.self))), + ] - public init(issues: Issue) { - self.init(snapshot: ["__typename": "Repository", "issues": issues.snapshot]) - } + public var snapshot: Snapshot - public var __typename: String { - get { - return snapshot["__typename"]! as! String - } - set { - snapshot.updateValue(newValue, forKey: "__typename") - } - } + public init(snapshot: Snapshot) { + self.snapshot = snapshot + } - /// A list of issues that have been opened in the repository. - public var issues: Issue { - get { - return Issue(snapshot: snapshot["issues"]! as! Snapshot) - } - set { - snapshot.updateValue(newValue.snapshot, forKey: "issues") + public init(state: StatusState) { + self.init(snapshot: ["__typename": "Status", "state": state]) + } + + public var __typename: String { + get { + return snapshot["__typename"]! as! String + } + set { + snapshot.updateValue(newValue, forKey: "__typename") + } + } + + /// The combined commit status. + public var state: StatusState { + get { + return snapshot["state"]! as! StatusState + } + set { + snapshot.updateValue(newValue, forKey: "state") + } + } + } + } + } + } } } - public struct Issue: GraphQLSelectionSet { - public static let possibleTypes = ["IssueConnection"] + public struct PageInfo: GraphQLSelectionSet { + public static let possibleTypes = ["PageInfo"] public static let selections: [GraphQLSelection] = [ GraphQLField("__typename", type: .nonNull(.scalar(String.self))), - GraphQLField("nodes", type: .list(.object(Node.selections))), - GraphQLField("pageInfo", type: .nonNull(.object(PageInfo.selections))), + GraphQLField("hasNextPage", type: .nonNull(.scalar(Bool.self))), + GraphQLField("endCursor", type: .scalar(String.self)), ] public var snapshot: Snapshot @@ -15527,8 +15552,8 @@ public final class RepoIssuePagesQuery: GraphQLQuery { self.snapshot = snapshot } - public init(nodes: [Node?]? = nil, pageInfo: PageInfo) { - self.init(snapshot: ["__typename": "IssueConnection", "nodes": nodes.flatMap { (value: [Node?]) -> [Snapshot?] in value.map { (value: Node?) -> Snapshot? in value.flatMap { (value: Node) -> Snapshot in value.snapshot } } }, "pageInfo": pageInfo.snapshot]) + public init(hasNextPage: Bool, endCursor: String? = nil) { + self.init(snapshot: ["__typename": "PageInfo", "hasNextPage": hasNextPage, "endCursor": endCursor]) } public var __typename: String { @@ -15540,819 +15565,23 @@ public final class RepoIssuePagesQuery: GraphQLQuery { } } - /// A list of nodes. - public var nodes: [Node?]? { + /// When paginating forwards, are there more items? + public var hasNextPage: Bool { get { - return (snapshot["nodes"] as? [Snapshot?]).flatMap { (value: [Snapshot?]) -> [Node?] in value.map { (value: Snapshot?) -> Node? in value.flatMap { (value: Snapshot) -> Node in Node(snapshot: value) } } } + return snapshot["hasNextPage"]! as! Bool } set { - snapshot.updateValue(newValue.flatMap { (value: [Node?]) -> [Snapshot?] in value.map { (value: Node?) -> Snapshot? in value.flatMap { (value: Node) -> Snapshot in value.snapshot } } }, forKey: "nodes") + snapshot.updateValue(newValue, forKey: "hasNextPage") } } - /// Information to aid in pagination. - public var pageInfo: PageInfo { + /// When paginating forwards, the cursor to continue. + public var endCursor: String? { get { - return PageInfo(snapshot: snapshot["pageInfo"]! as! Snapshot) + return snapshot["endCursor"] as? String } set { - snapshot.updateValue(newValue.snapshot, forKey: "pageInfo") - } - } - - public struct Node: GraphQLSelectionSet { - public static let possibleTypes = ["Issue"] - - public static let selections: [GraphQLSelection] = [ - GraphQLField("__typename", type: .nonNull(.scalar(String.self))), - GraphQLField("__typename", type: .nonNull(.scalar(String.self))), - GraphQLField("createdAt", type: .nonNull(.scalar(String.self))), - GraphQLField("author", type: .object(Author.selections)), - GraphQLField("__typename", type: .nonNull(.scalar(String.self))), - GraphQLField("id", type: .nonNull(.scalar(GraphQLID.self))), - GraphQLField("__typename", type: .nonNull(.scalar(String.self))), - GraphQLField("labels", arguments: ["first": 30], type: .object(Label.selections)), - GraphQLField("title", type: .nonNull(.scalar(String.self))), - GraphQLField("number", type: .nonNull(.scalar(Int.self))), - GraphQLField("state", type: .nonNull(.scalar(IssueState.self))), - ] - - public var snapshot: Snapshot - - public init(snapshot: Snapshot) { - self.snapshot = snapshot - } - - public init(createdAt: String, author: Author? = nil, id: GraphQLID, labels: Label? = nil, title: String, number: Int, state: IssueState) { - self.init(snapshot: ["__typename": "Issue", "createdAt": createdAt, "author": author.flatMap { (value: Author) -> Snapshot in value.snapshot }, "id": id, "labels": labels.flatMap { (value: Label) -> Snapshot in value.snapshot }, "title": title, "number": number, "state": state]) - } - - public var __typename: String { - get { - return snapshot["__typename"]! as! String - } - set { - snapshot.updateValue(newValue, forKey: "__typename") - } - } - - /// Identifies the date and time when the object was created. - public var createdAt: String { - get { - return snapshot["createdAt"]! as! String - } - set { - snapshot.updateValue(newValue, forKey: "createdAt") - } - } - - /// The actor who authored the comment. - public var author: Author? { - get { - return (snapshot["author"] as? Snapshot).flatMap { Author(snapshot: $0) } - } - set { - snapshot.updateValue(newValue?.snapshot, forKey: "author") - } - } - - /// ID of the object. - public var id: GraphQLID { - get { - return snapshot["id"]! as! GraphQLID - } - set { - snapshot.updateValue(newValue, forKey: "id") - } - } - - /// A list of labels associated with the object. - public var labels: Label? { - get { - return (snapshot["labels"] as? Snapshot).flatMap { Label(snapshot: $0) } - } - set { - snapshot.updateValue(newValue?.snapshot, forKey: "labels") - } - } - - /// Identifies the issue title. - public var title: String { - get { - return snapshot["title"]! as! String - } - set { - snapshot.updateValue(newValue, forKey: "title") - } - } - - /// Identifies the issue number. - public var number: Int { - get { - return snapshot["number"]! as! Int - } - set { - snapshot.updateValue(newValue, forKey: "number") - } - } - - /// Identifies the state of the issue. - public var state: IssueState { - get { - return snapshot["state"]! as! IssueState - } - set { - snapshot.updateValue(newValue, forKey: "state") - } - } - - public var fragments: Fragments { - get { - return Fragments(snapshot: snapshot) - } - set { - snapshot += newValue.snapshot - } - } - - public struct Fragments { - public var snapshot: Snapshot - - public var repoEventFields: RepoEventFields { - get { - return RepoEventFields(snapshot: snapshot) - } - set { - snapshot += newValue.snapshot - } - } - - public var nodeFields: NodeFields { - get { - return NodeFields(snapshot: snapshot) - } - set { - snapshot += newValue.snapshot - } - } - - public var labelableFields: LabelableFields { - get { - return LabelableFields(snapshot: snapshot) - } - set { - snapshot += newValue.snapshot - } - } - } - - public struct Author: GraphQLSelectionSet { - public static let possibleTypes = ["Organization", "User", "Bot"] - - public static let selections: [GraphQLSelection] = [ - GraphQLField("__typename", type: .nonNull(.scalar(String.self))), - GraphQLField("login", type: .nonNull(.scalar(String.self))), - ] - - public var snapshot: Snapshot - - public init(snapshot: Snapshot) { - self.snapshot = snapshot - } - - public static func makeOrganization(login: String) -> Author { - return Author(snapshot: ["__typename": "Organization", "login": login]) - } - - public static func makeUser(login: String) -> Author { - return Author(snapshot: ["__typename": "User", "login": login]) - } - - public static func makeBot(login: String) -> Author { - return Author(snapshot: ["__typename": "Bot", "login": login]) - } - - public var __typename: String { - get { - return snapshot["__typename"]! as! String - } - set { - snapshot.updateValue(newValue, forKey: "__typename") - } - } - - /// The username of the actor. - public var login: String { - get { - return snapshot["login"]! as! String - } - set { - snapshot.updateValue(newValue, forKey: "login") - } - } - } - - public struct Label: GraphQLSelectionSet { - public static let possibleTypes = ["LabelConnection"] - - public static let selections: [GraphQLSelection] = [ - GraphQLField("__typename", type: .nonNull(.scalar(String.self))), - GraphQLField("nodes", type: .list(.object(Node.selections))), - ] - - public var snapshot: Snapshot - - public init(snapshot: Snapshot) { - self.snapshot = snapshot - } - - public init(nodes: [Node?]? = nil) { - self.init(snapshot: ["__typename": "LabelConnection", "nodes": nodes.flatMap { (value: [Node?]) -> [Snapshot?] in value.map { (value: Node?) -> Snapshot? in value.flatMap { (value: Node) -> Snapshot in value.snapshot } } }]) - } - - public var __typename: String { - get { - return snapshot["__typename"]! as! String - } - set { - snapshot.updateValue(newValue, forKey: "__typename") - } - } - - /// A list of nodes. - public var nodes: [Node?]? { - get { - return (snapshot["nodes"] as? [Snapshot?]).flatMap { (value: [Snapshot?]) -> [Node?] in value.map { (value: Snapshot?) -> Node? in value.flatMap { (value: Snapshot) -> Node in Node(snapshot: value) } } } - } - set { - snapshot.updateValue(newValue.flatMap { (value: [Node?]) -> [Snapshot?] in value.map { (value: Node?) -> Snapshot? in value.flatMap { (value: Node) -> Snapshot in value.snapshot } } }, forKey: "nodes") - } - } - - public struct Node: GraphQLSelectionSet { - public static let possibleTypes = ["Label"] - - public static let selections: [GraphQLSelection] = [ - GraphQLField("__typename", type: .nonNull(.scalar(String.self))), - GraphQLField("color", type: .nonNull(.scalar(String.self))), - GraphQLField("name", type: .nonNull(.scalar(String.self))), - ] - - public var snapshot: Snapshot - - public init(snapshot: Snapshot) { - self.snapshot = snapshot - } - - public init(color: String, name: String) { - self.init(snapshot: ["__typename": "Label", "color": color, "name": name]) - } - - public var __typename: String { - get { - return snapshot["__typename"]! as! String - } - set { - snapshot.updateValue(newValue, forKey: "__typename") - } - } - - /// Identifies the label color. - public var color: String { - get { - return snapshot["color"]! as! String - } - set { - snapshot.updateValue(newValue, forKey: "color") - } - } - - /// Identifies the label name. - public var name: String { - get { - return snapshot["name"]! as! String - } - set { - snapshot.updateValue(newValue, forKey: "name") - } - } - } - } - } - - public struct PageInfo: GraphQLSelectionSet { - public static let possibleTypes = ["PageInfo"] - - public static let selections: [GraphQLSelection] = [ - GraphQLField("__typename", type: .nonNull(.scalar(String.self))), - GraphQLField("hasNextPage", type: .nonNull(.scalar(Bool.self))), - GraphQLField("endCursor", type: .scalar(String.self)), - ] - - public var snapshot: Snapshot - - public init(snapshot: Snapshot) { - self.snapshot = snapshot - } - - public init(hasNextPage: Bool, endCursor: String? = nil) { - self.init(snapshot: ["__typename": "PageInfo", "hasNextPage": hasNextPage, "endCursor": endCursor]) - } - - public var __typename: String { - get { - return snapshot["__typename"]! as! String - } - set { - snapshot.updateValue(newValue, forKey: "__typename") - } - } - - /// When paginating forwards, are there more items? - public var hasNextPage: Bool { - get { - return snapshot["hasNextPage"]! as! Bool - } - set { - snapshot.updateValue(newValue, forKey: "hasNextPage") - } - } - - /// When paginating forwards, the cursor to continue. - public var endCursor: String? { - get { - return snapshot["endCursor"] as? String - } - set { - snapshot.updateValue(newValue, forKey: "endCursor") - } - } - } - } - } - } -} - -public final class RepoPullRequestPagesQuery: GraphQLQuery { - public static let operationString = - "query RepoPullRequestPages($owner: String!, $name: String!, $after: String, $page_size: Int!) {\n repository(owner: $owner, name: $name) {\n __typename\n pullRequests(first: $page_size, orderBy: {field: CREATED_AT, direction: DESC}, states: [OPEN, CLOSED, MERGED], after: $after) {\n __typename\n nodes {\n __typename\n ...repoEventFields\n ...nodeFields\n ...labelableFields\n title\n number\n state\n }\n pageInfo {\n __typename\n hasNextPage\n endCursor\n }\n }\n }\n}" - - public static var requestString: String { return operationString.appending(RepoEventFields.fragmentString).appending(NodeFields.fragmentString).appending(LabelableFields.fragmentString) } - - public var owner: String - public var name: String - public var after: String? - public var page_size: Int - - public init(owner: String, name: String, after: String? = nil, page_size: Int) { - self.owner = owner - self.name = name - self.after = after - self.page_size = page_size - } - - public var variables: GraphQLMap? { - return ["owner": owner, "name": name, "after": after, "page_size": page_size] - } - - public struct Data: GraphQLSelectionSet { - public static let possibleTypes = ["Query"] - - public static let selections: [GraphQLSelection] = [ - GraphQLField("repository", arguments: ["owner": GraphQLVariable("owner"), "name": GraphQLVariable("name")], type: .object(Repository.selections)), - ] - - public var snapshot: Snapshot - - public init(snapshot: Snapshot) { - self.snapshot = snapshot - } - - public init(repository: Repository? = nil) { - self.init(snapshot: ["__typename": "Query", "repository": repository.flatMap { (value: Repository) -> Snapshot in value.snapshot }]) - } - - /// Lookup a given repository by the owner and repository name. - public var repository: Repository? { - get { - return (snapshot["repository"] as? Snapshot).flatMap { Repository(snapshot: $0) } - } - set { - snapshot.updateValue(newValue?.snapshot, forKey: "repository") - } - } - - public struct Repository: GraphQLSelectionSet { - public static let possibleTypes = ["Repository"] - - public static let selections: [GraphQLSelection] = [ - GraphQLField("__typename", type: .nonNull(.scalar(String.self))), - GraphQLField("pullRequests", arguments: ["first": GraphQLVariable("page_size"), "orderBy": ["field": "CREATED_AT", "direction": "DESC"], "states": ["OPEN", "CLOSED", "MERGED"], "after": GraphQLVariable("after")], type: .nonNull(.object(PullRequest.selections))), - ] - - public var snapshot: Snapshot - - public init(snapshot: Snapshot) { - self.snapshot = snapshot - } - - public init(pullRequests: PullRequest) { - self.init(snapshot: ["__typename": "Repository", "pullRequests": pullRequests.snapshot]) - } - - public var __typename: String { - get { - return snapshot["__typename"]! as! String - } - set { - snapshot.updateValue(newValue, forKey: "__typename") - } - } - - /// A list of pull requests that have been opened in the repository. - public var pullRequests: PullRequest { - get { - return PullRequest(snapshot: snapshot["pullRequests"]! as! Snapshot) - } - set { - snapshot.updateValue(newValue.snapshot, forKey: "pullRequests") - } - } - - public struct PullRequest: GraphQLSelectionSet { - public static let possibleTypes = ["PullRequestConnection"] - - public static let selections: [GraphQLSelection] = [ - GraphQLField("__typename", type: .nonNull(.scalar(String.self))), - GraphQLField("nodes", type: .list(.object(Node.selections))), - GraphQLField("pageInfo", type: .nonNull(.object(PageInfo.selections))), - ] - - public var snapshot: Snapshot - - public init(snapshot: Snapshot) { - self.snapshot = snapshot - } - - public init(nodes: [Node?]? = nil, pageInfo: PageInfo) { - self.init(snapshot: ["__typename": "PullRequestConnection", "nodes": nodes.flatMap { (value: [Node?]) -> [Snapshot?] in value.map { (value: Node?) -> Snapshot? in value.flatMap { (value: Node) -> Snapshot in value.snapshot } } }, "pageInfo": pageInfo.snapshot]) - } - - public var __typename: String { - get { - return snapshot["__typename"]! as! String - } - set { - snapshot.updateValue(newValue, forKey: "__typename") - } - } - - /// A list of nodes. - public var nodes: [Node?]? { - get { - return (snapshot["nodes"] as? [Snapshot?]).flatMap { (value: [Snapshot?]) -> [Node?] in value.map { (value: Snapshot?) -> Node? in value.flatMap { (value: Snapshot) -> Node in Node(snapshot: value) } } } - } - set { - snapshot.updateValue(newValue.flatMap { (value: [Node?]) -> [Snapshot?] in value.map { (value: Node?) -> Snapshot? in value.flatMap { (value: Node) -> Snapshot in value.snapshot } } }, forKey: "nodes") - } - } - - /// Information to aid in pagination. - public var pageInfo: PageInfo { - get { - return PageInfo(snapshot: snapshot["pageInfo"]! as! Snapshot) - } - set { - snapshot.updateValue(newValue.snapshot, forKey: "pageInfo") - } - } - - public struct Node: GraphQLSelectionSet { - public static let possibleTypes = ["PullRequest"] - - public static let selections: [GraphQLSelection] = [ - GraphQLField("__typename", type: .nonNull(.scalar(String.self))), - GraphQLField("__typename", type: .nonNull(.scalar(String.self))), - GraphQLField("createdAt", type: .nonNull(.scalar(String.self))), - GraphQLField("author", type: .object(Author.selections)), - GraphQLField("__typename", type: .nonNull(.scalar(String.self))), - GraphQLField("id", type: .nonNull(.scalar(GraphQLID.self))), - GraphQLField("__typename", type: .nonNull(.scalar(String.self))), - GraphQLField("labels", arguments: ["first": 30], type: .object(Label.selections)), - GraphQLField("title", type: .nonNull(.scalar(String.self))), - GraphQLField("number", type: .nonNull(.scalar(Int.self))), - GraphQLField("state", type: .nonNull(.scalar(PullRequestState.self))), - ] - - public var snapshot: Snapshot - - public init(snapshot: Snapshot) { - self.snapshot = snapshot - } - - public init(createdAt: String, author: Author? = nil, id: GraphQLID, labels: Label? = nil, title: String, number: Int, state: PullRequestState) { - self.init(snapshot: ["__typename": "PullRequest", "createdAt": createdAt, "author": author.flatMap { (value: Author) -> Snapshot in value.snapshot }, "id": id, "labels": labels.flatMap { (value: Label) -> Snapshot in value.snapshot }, "title": title, "number": number, "state": state]) - } - - public var __typename: String { - get { - return snapshot["__typename"]! as! String - } - set { - snapshot.updateValue(newValue, forKey: "__typename") - } - } - - /// Identifies the date and time when the object was created. - public var createdAt: String { - get { - return snapshot["createdAt"]! as! String - } - set { - snapshot.updateValue(newValue, forKey: "createdAt") - } - } - - /// The actor who authored the comment. - public var author: Author? { - get { - return (snapshot["author"] as? Snapshot).flatMap { Author(snapshot: $0) } - } - set { - snapshot.updateValue(newValue?.snapshot, forKey: "author") - } - } - - /// ID of the object. - public var id: GraphQLID { - get { - return snapshot["id"]! as! GraphQLID - } - set { - snapshot.updateValue(newValue, forKey: "id") - } - } - - /// A list of labels associated with the object. - public var labels: Label? { - get { - return (snapshot["labels"] as? Snapshot).flatMap { Label(snapshot: $0) } - } - set { - snapshot.updateValue(newValue?.snapshot, forKey: "labels") - } - } - - /// Identifies the pull request title. - public var title: String { - get { - return snapshot["title"]! as! String - } - set { - snapshot.updateValue(newValue, forKey: "title") - } - } - - /// Identifies the pull request number. - public var number: Int { - get { - return snapshot["number"]! as! Int - } - set { - snapshot.updateValue(newValue, forKey: "number") - } - } - - /// Identifies the state of the pull request. - public var state: PullRequestState { - get { - return snapshot["state"]! as! PullRequestState - } - set { - snapshot.updateValue(newValue, forKey: "state") - } - } - - public var fragments: Fragments { - get { - return Fragments(snapshot: snapshot) - } - set { - snapshot += newValue.snapshot - } - } - - public struct Fragments { - public var snapshot: Snapshot - - public var repoEventFields: RepoEventFields { - get { - return RepoEventFields(snapshot: snapshot) - } - set { - snapshot += newValue.snapshot - } - } - - public var nodeFields: NodeFields { - get { - return NodeFields(snapshot: snapshot) - } - set { - snapshot += newValue.snapshot - } - } - - public var labelableFields: LabelableFields { - get { - return LabelableFields(snapshot: snapshot) - } - set { - snapshot += newValue.snapshot - } - } - } - - public struct Author: GraphQLSelectionSet { - public static let possibleTypes = ["Organization", "User", "Bot"] - - public static let selections: [GraphQLSelection] = [ - GraphQLField("__typename", type: .nonNull(.scalar(String.self))), - GraphQLField("login", type: .nonNull(.scalar(String.self))), - ] - - public var snapshot: Snapshot - - public init(snapshot: Snapshot) { - self.snapshot = snapshot - } - - public static func makeOrganization(login: String) -> Author { - return Author(snapshot: ["__typename": "Organization", "login": login]) - } - - public static func makeUser(login: String) -> Author { - return Author(snapshot: ["__typename": "User", "login": login]) - } - - public static func makeBot(login: String) -> Author { - return Author(snapshot: ["__typename": "Bot", "login": login]) - } - - public var __typename: String { - get { - return snapshot["__typename"]! as! String - } - set { - snapshot.updateValue(newValue, forKey: "__typename") - } - } - - /// The username of the actor. - public var login: String { - get { - return snapshot["login"]! as! String - } - set { - snapshot.updateValue(newValue, forKey: "login") - } - } - } - - public struct Label: GraphQLSelectionSet { - public static let possibleTypes = ["LabelConnection"] - - public static let selections: [GraphQLSelection] = [ - GraphQLField("__typename", type: .nonNull(.scalar(String.self))), - GraphQLField("nodes", type: .list(.object(Node.selections))), - ] - - public var snapshot: Snapshot - - public init(snapshot: Snapshot) { - self.snapshot = snapshot - } - - public init(nodes: [Node?]? = nil) { - self.init(snapshot: ["__typename": "LabelConnection", "nodes": nodes.flatMap { (value: [Node?]) -> [Snapshot?] in value.map { (value: Node?) -> Snapshot? in value.flatMap { (value: Node) -> Snapshot in value.snapshot } } }]) - } - - public var __typename: String { - get { - return snapshot["__typename"]! as! String - } - set { - snapshot.updateValue(newValue, forKey: "__typename") - } - } - - /// A list of nodes. - public var nodes: [Node?]? { - get { - return (snapshot["nodes"] as? [Snapshot?]).flatMap { (value: [Snapshot?]) -> [Node?] in value.map { (value: Snapshot?) -> Node? in value.flatMap { (value: Snapshot) -> Node in Node(snapshot: value) } } } - } - set { - snapshot.updateValue(newValue.flatMap { (value: [Node?]) -> [Snapshot?] in value.map { (value: Node?) -> Snapshot? in value.flatMap { (value: Node) -> Snapshot in value.snapshot } } }, forKey: "nodes") - } - } - - public struct Node: GraphQLSelectionSet { - public static let possibleTypes = ["Label"] - - public static let selections: [GraphQLSelection] = [ - GraphQLField("__typename", type: .nonNull(.scalar(String.self))), - GraphQLField("color", type: .nonNull(.scalar(String.self))), - GraphQLField("name", type: .nonNull(.scalar(String.self))), - ] - - public var snapshot: Snapshot - - public init(snapshot: Snapshot) { - self.snapshot = snapshot - } - - public init(color: String, name: String) { - self.init(snapshot: ["__typename": "Label", "color": color, "name": name]) - } - - public var __typename: String { - get { - return snapshot["__typename"]! as! String - } - set { - snapshot.updateValue(newValue, forKey: "__typename") - } - } - - /// Identifies the label color. - public var color: String { - get { - return snapshot["color"]! as! String - } - set { - snapshot.updateValue(newValue, forKey: "color") - } - } - - /// Identifies the label name. - public var name: String { - get { - return snapshot["name"]! as! String - } - set { - snapshot.updateValue(newValue, forKey: "name") - } - } - } - } - } - - public struct PageInfo: GraphQLSelectionSet { - public static let possibleTypes = ["PageInfo"] - - public static let selections: [GraphQLSelection] = [ - GraphQLField("__typename", type: .nonNull(.scalar(String.self))), - GraphQLField("hasNextPage", type: .nonNull(.scalar(Bool.self))), - GraphQLField("endCursor", type: .scalar(String.self)), - ] - - public var snapshot: Snapshot - - public init(snapshot: Snapshot) { - self.snapshot = snapshot - } - - public init(hasNextPage: Bool, endCursor: String? = nil) { - self.init(snapshot: ["__typename": "PageInfo", "hasNextPage": hasNextPage, "endCursor": endCursor]) - } - - public var __typename: String { - get { - return snapshot["__typename"]! as! String - } - set { - snapshot.updateValue(newValue, forKey: "__typename") - } - } - - /// When paginating forwards, are there more items? - public var hasNextPage: Bool { - get { - return snapshot["hasNextPage"]! as! Bool - } - set { - snapshot.updateValue(newValue, forKey: "hasNextPage") - } - } - - /// When paginating forwards, the cursor to continue. - public var endCursor: String? { - get { - return snapshot["endCursor"] as? String - } - set { - snapshot.updateValue(newValue, forKey: "endCursor") - } + snapshot.updateValue(newValue, forKey: "endCursor") } } } diff --git a/gql/RepoPages.graphql b/gql/RepoPages.graphql index 8511a4c8c..518746374 100644 --- a/gql/RepoPages.graphql +++ b/gql/RepoPages.graphql @@ -16,6 +16,15 @@ query RepoSearchPages($query: String!, $after: String, $page_size: Int!) { title number pullRequestState: state + commits(last: 1) { + nodes { + commit { + status { + state + } + } + } + } } } pageInfo { @@ -24,41 +33,3 @@ query RepoSearchPages($query: String!, $after: String, $page_size: Int!) { } } } - -query RepoIssuePages($owner: String!, $name: String!, $after: String, $page_size: Int!) { - repository(owner: $owner, name: $name) { - issues(first: $page_size, orderBy: {field: CREATED_AT, direction: DESC}, states: [OPEN, CLOSED], after: $after) { - nodes { - ...repoEventFields - ...nodeFields - ...labelableFields - title - number - state - } - pageInfo { - hasNextPage - endCursor - } - } - } -} - -query RepoPullRequestPages($owner: String!, $name: String!, $after: String, $page_size: Int!) { - repository(owner: $owner, name: $name) { - pullRequests(first: $page_size, orderBy: {field: CREATED_AT, direction: DESC}, states: [OPEN, CLOSED, MERGED], after: $after) { - nodes { - ...repoEventFields - ...nodeFields - ...labelableFields - title - number - state - } - pageInfo { - hasNextPage - endCursor - } - } - } -}