diff --git a/CHANGELOG.md b/CHANGELOG.md index d93a62bb..765e970d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ --> ## Master +- Adds mergeable state property in the Github PR struct [@Juanpe][] - [#318](https://github.com/danger/swift/pull/318) ## 3.1.0 diff --git a/Documentation/reference/structs/GitHubPR.md b/Documentation/reference/structs/GitHubPR.md index 2bd7ba88..b3a4d1d1 100644 --- a/Documentation/reference/structs/GitHubPR.md +++ b/Documentation/reference/structs/GitHubPR.md @@ -127,6 +127,14 @@ public let isMerged: Bool? > A boolean indicating if the pull request has been merged. +### `mergeable` + +```swift +public let mergeable: MergeableState +``` + +> The state for mergeable based on the existence of merge conflicts: conflicting, mergeable, unknown. + ### `commitCount` ```swift diff --git a/Documentation/reference/structs/PullRequest.md b/Documentation/reference/structs/PullRequest.md index c62b839c..b4fd1ba0 100644 --- a/Documentation/reference/structs/PullRequest.md +++ b/Documentation/reference/structs/PullRequest.md @@ -127,6 +127,14 @@ public let isMerged: Bool? > A boolean indicating if the pull request has been merged. +### `mergeable` + +```swift +public let mergeable: MergeableState +``` + +> The state for mergeable based on the existence of merge conflicts: conflicting, mergeable, unknown. + ### `commitCount` ```swift diff --git a/Sources/Danger/GitHubDSL.swift b/Sources/Danger/GitHubDSL.swift index b343c18b..aa27d921 100644 --- a/Sources/Danger/GitHubDSL.swift +++ b/Sources/Danger/GitHubDSL.swift @@ -42,6 +42,7 @@ extension GitHub { case state case head case base + case mergeable case isLocked = "locked" case isMerged = "merged" case createdAt = "created_at" @@ -61,6 +62,12 @@ extension GitHub { case merged case locked } + + public enum MergeableState: String, Decodable { + case conflicting + case mergeable + case unknown + } /// The number of the pull request. public let number: Int @@ -106,6 +113,9 @@ extension GitHub { /// A boolean indicating if the pull request has been merged. public let isMerged: Bool? + + /// The state for mergeable based on the existence of merge conflicts: conflicting, mergeable, unknown. + public let mergeable: MergeableState /// The number of commits in the pull request. public let commitCount: Int? diff --git a/Sources/DangerFixtures/DangerDSLResources/CustomGitHubDSL.swift b/Sources/DangerFixtures/DangerDSLResources/CustomGitHubDSL.swift index 4110aa2d..2cde03f6 100644 --- a/Sources/DangerFixtures/DangerDSLResources/CustomGitHubDSL.swift +++ b/Sources/DangerFixtures/DangerDSLResources/CustomGitHubDSL.swift @@ -495,6 +495,7 @@ public func githubJSONWithFiles(created: [String] = [], modified: [String] = [], "updated_at": "2016-08-17T15:26:15Z", "closed_at": "2016-08-17T15:26:14Z", "merged_at": "2016-08-17T15:26:14Z", + "mergeable": "mergeable", "merge_commit_sha": "e80bc6c78cd2f3524577e1401d7a460feba7a26c", "assignee": { "login": "orta", @@ -800,9 +801,8 @@ public func githubJSONWithFiles(created: [String] = [], modified: [String] = [], }, "author_association": "MEMBER", "merged": true, - "mergeable": null, + "mergeable": "mergeable", "rebaseable": null, - "mergeable_state": "unknown", "merged_by": { "login": "ashfurrow", "id": 498212, diff --git a/Sources/DangerFixtures/DangerDSLResources/DangerDSLGitHub.swift b/Sources/DangerFixtures/DangerDSLResources/DangerDSLGitHub.swift index d7c934b9..a4be0743 100644 --- a/Sources/DangerFixtures/DangerDSLResources/DangerDSLGitHub.swift +++ b/Sources/DangerFixtures/DangerDSLResources/DangerDSLGitHub.swift @@ -543,6 +543,7 @@ public let DSLGitHubJSON = """ "updated_at": "2016-08-17T15:26:15Z", "closed_at": "2016-08-17T15:26:14Z", "merged_at": "2016-08-17T15:26:14Z", + "mergeable": "mergeable", "merge_commit_sha": "e80bc6c78cd2f3524577e1401d7a460feba7a26c", "assignee": { "login": "orta", @@ -848,9 +849,8 @@ public let DSLGitHubJSON = """ }, "author_association": "MEMBER", "merged": true, - "mergeable": null, + "mergeable": "conflicting", "rebaseable": null, - "mergeable_state": "unknown", "merged_by": { "login": "ashfurrow", "id": 498212, diff --git a/Sources/DangerFixtures/DangerDSLResources/DangerDSLGitHubEnterprise.swift b/Sources/DangerFixtures/DangerDSLResources/DangerDSLGitHubEnterprise.swift index 6b3189fd..4dd35f97 100644 --- a/Sources/DangerFixtures/DangerDSLResources/DangerDSLGitHubEnterprise.swift +++ b/Sources/DangerFixtures/DangerDSLResources/DangerDSLGitHubEnterprise.swift @@ -543,6 +543,7 @@ public let DSLGitHubEnterpriseJSON = """ "updated_at": "2016-08-17T15:26:15Z", "closed_at": "2016-08-17T15:26:14Z", "merged_at": "2016-08-17T15:26:14Z", + "mergeable": "mergeable", "merge_commit_sha": "e80bc6c78cd2f3524577e1401d7a460feba7a26c", "assignee": { "login": "orta", @@ -848,9 +849,8 @@ public let DSLGitHubEnterpriseJSON = """ }, "author_association": "MEMBER", "merged": true, - "mergeable": null, "rebaseable": null, - "mergeable_state": "unknown", + "mergeable": "mergeable", "merged_by": { "login": "ashfurrow", "id": 498212, diff --git a/Tests/DangerTests/GitHubTestResources/GitHubPR.swift b/Tests/DangerTests/GitHubTestResources/GitHubPR.swift index c7ce72b1..92859a12 100644 --- a/Tests/DangerTests/GitHubTestResources/GitHubPR.swift +++ b/Tests/DangerTests/GitHubTestResources/GitHubPR.swift @@ -14,6 +14,7 @@ public let GitHubPRJSON = """ "statuses_url": "https://api.github.com/repos/octocat/Hello-World/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e", "number": 1347, "state": "open", +"mergeable": "mergeable", "title": "new-feature", "body": "Please pull these awesome changes", "assignee": { diff --git a/fixtures/eidolon_609.json b/fixtures/eidolon_609.json index 67d0031b..276020c5 100644 --- a/fixtures/eidolon_609.json +++ b/fixtures/eidolon_609.json @@ -845,9 +845,8 @@ }, "author_association": "MEMBER", "merged": true, - "mergeable": null, + "mergeable": "mergeable", "rebaseable": null, - "mergeable_state": "unknown", "merged_by": { "login": "ashfurrow", "id": 498212,