Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds mergeable state property in the Github PR struct #318

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 8 additions & 0 deletions Documentation/reference/structs/GitHubPR.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions Documentation/reference/structs/PullRequest.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions Sources/Danger/GitHubDSL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ extension GitHub {
case state
case head
case base
case mergeable
case isLocked = "locked"
case isMerged = "merged"
case createdAt = "created_at"
Expand All @@ -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
Expand Down Expand Up @@ -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?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions Tests/DangerTests/GitHubTestResources/GitHubPR.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
3 changes: 1 addition & 2 deletions fixtures/eidolon_609.json
Original file line number Diff line number Diff line change
Expand Up @@ -845,9 +845,8 @@
},
"author_association": "MEMBER",
"merged": true,
"mergeable": null,
"mergeable": "mergeable",
"rebaseable": null,
"mergeable_state": "unknown",
"merged_by": {
"login": "ashfurrow",
"id": 498212,
Expand Down