diff --git a/scm/driver/azure/pr.go b/scm/driver/azure/pr.go index a5bb9347..d2e36c48 100644 --- a/scm/driver/azure/pr.go +++ b/scm/driver/azure/pr.go @@ -107,6 +107,7 @@ type pr struct { SourceRefName string `json:"sourceRefName"` TargetRefName string `json:"targetRefName"` MergeStatus string `json:"mergeStatus"` + IsDraft bool `json:"isDraft"` MergeID string `json:"mergeId"` LastMergeSourceCommit struct { CommitID string `json:"commitId"` @@ -168,6 +169,7 @@ func convertPullRequest(from *pr) *scm.PullRequest { Source: scm.TrimRef(from.SourceRefName), Target: scm.TrimRef(from.TargetRefName), Link: from.URL, + Draft: from.IsDraft, Closed: from.ClosedDate.Valid, Merged: from.Status == "completed", Ref: fmt.Sprintf("refs/pull/%d/merge", from.PullRequestID), diff --git a/scm/driver/azure/testdata/pr.json b/scm/driver/azure/testdata/pr.json index e419af01..01c08b31 100644 --- a/scm/driver/azure/testdata/pr.json +++ b/scm/driver/azure/testdata/pr.json @@ -30,6 +30,7 @@ "sourceRefName": "refs/heads/pr_branch", "targetRefName": "refs/heads/main", "mergeStatus": "queued", + "isDraft": false, "mergeId": "36c88bf7-3d14-437f-82aa-e38cce733261", "lastMergeSourceCommit": { "commitId": "01768d964c03e97260af0bd8cd9e5cd1f9ac6356", diff --git a/scm/driver/azure/testdata/pr.json.golden b/scm/driver/azure/testdata/pr.json.golden index 5e59c583..23330a15 100644 --- a/scm/driver/azure/testdata/pr.json.golden +++ b/scm/driver/azure/testdata/pr.json.golden @@ -10,6 +10,7 @@ "Fork": "", "Link": "https://dev.azure.com/tphoney/d350c9c0-7749-4ff8-a78f-f9c1f0e56729/_apis/git/repositories/fde2d21f-13b9-4864-a995-83329045289a/pullRequests/19", "Diff": "", + "Draft": false, "Closed": true, "Merged": true, "Base": { diff --git a/scm/driver/github/pr.go b/scm/driver/github/pr.go index 74da3bbf..52e98093 100644 --- a/scm/driver/github/pr.go +++ b/scm/driver/github/pr.go @@ -76,6 +76,7 @@ type pr struct { State string `json:"state"` Title string `json:"title"` Body string `json:"body"` + Draft bool `json:"draft"` DiffURL string `json:"diff_url"` HTMLURL string `json:"html_url"` User struct { @@ -154,6 +155,7 @@ func convertPullRequest(from *pr) *scm.PullRequest { Fork: from.Head.Repo.FullName, Link: from.HTMLURL, Diff: from.DiffURL, + Draft: from.Draft, Closed: from.State != "open", Merged: from.MergedAt.String != "", Head: scm.Reference{ diff --git a/scm/driver/github/testdata/pr.json b/scm/driver/github/testdata/pr.json index edcc02d7..3315fafb 100644 --- a/scm/driver/github/testdata/pr.json +++ b/scm/driver/github/testdata/pr.json @@ -11,6 +11,7 @@ "comments_url": "https://api.github.com/repos/octocat/Hello-World/issues/1347/comments", "statuses_url": "https://api.github.com/repos/octocat/Hello-World/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e", "number": 1347, + "draft": false, "state": "open", "title": "new-feature", "body": "Please pull these awesome changes", diff --git a/scm/driver/github/testdata/pr.json.golden b/scm/driver/github/testdata/pr.json.golden index 2ea51c70..5bf11ba0 100644 --- a/scm/driver/github/testdata/pr.json.golden +++ b/scm/driver/github/testdata/pr.json.golden @@ -9,6 +9,7 @@ "Fork": "octocat/Hello-World", "Link": "https://github.com/octocat/Hello-World/pull/1347", "Diff": "https://github.com/octocat/Hello-World/pull/1347.diff", + "Draft": false, "Closed": false, "Merged": true, "Base": { diff --git a/scm/driver/github/testdata/pulls.json b/scm/driver/github/testdata/pulls.json index 611d7d71..e1f85a07 100644 --- a/scm/driver/github/testdata/pulls.json +++ b/scm/driver/github/testdata/pulls.json @@ -12,6 +12,7 @@ "comments_url": "https://api.github.com/repos/octocat/Hello-World/issues/1347/comments", "statuses_url": "https://api.github.com/repos/octocat/Hello-World/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e", "number": 1347, + "draft": false, "state": "open", "title": "new-feature", "body": "Please pull these awesome changes", diff --git a/scm/driver/github/testdata/pulls.json.golden b/scm/driver/github/testdata/pulls.json.golden index 1a6798b9..f2a97473 100644 --- a/scm/driver/github/testdata/pulls.json.golden +++ b/scm/driver/github/testdata/pulls.json.golden @@ -10,6 +10,7 @@ "Fork": "octocat/Hello-World", "Link": "https://github.com/octocat/Hello-World/pull/1347", "Diff": "https://github.com/octocat/Hello-World/pull/1347.diff", + "Draft": false, "Closed": false, "Merged": true, "Base": { diff --git a/scm/driver/gitlab/pr.go b/scm/driver/gitlab/pr.go index 52548146..b8f67719 100644 --- a/scm/driver/gitlab/pr.go +++ b/scm/driver/gitlab/pr.go @@ -99,13 +99,14 @@ func (s *pullService) Close(ctx context.Context, repo string, number int) (*scm. } type pr struct { - Number int `json:"iid"` - Sha string `json:"sha"` - Title string `json:"title"` - Desc string `json:"description"` - State string `json:"state"` - Link string `json:"web_url"` - Author struct { + Number int `json:"iid"` + Sha string `json:"sha"` + Title string `json:"title"` + Desc string `json:"description"` + State string `json:"state"` + WorkInProgress bool `json:"work_in_progress"` + Link string `json:"web_url"` + Author struct { Username string `json:"username"` Email string `json:"email"` Name string `json:"name"` @@ -160,6 +161,7 @@ func convertPullRequest(from *pr) *scm.PullRequest { Source: from.SourceBranch, Target: from.TargetBranch, Link: from.Link, + Draft: from.WorkInProgress, Closed: from.State != "opened", Merged: from.State == "merged", Author: scm.User{ diff --git a/scm/driver/gitlab/testdata/merge.json.golden b/scm/driver/gitlab/testdata/merge.json.golden index 4df0d249..5864162c 100644 --- a/scm/driver/gitlab/testdata/merge.json.golden +++ b/scm/driver/gitlab/testdata/merge.json.golden @@ -7,6 +7,7 @@ "Source": "fix", "Target": "master", "Link": "https://gitlab.com/gitlab-org/testme/merge_requests/1", + "Draft": false, "Closed": true, "Merged": false, "Author": { diff --git a/scm/driver/gitlab/testdata/merges.json.golden b/scm/driver/gitlab/testdata/merges.json.golden index 46cb6d7c..cf605b9e 100644 --- a/scm/driver/gitlab/testdata/merges.json.golden +++ b/scm/driver/gitlab/testdata/merges.json.golden @@ -8,6 +8,7 @@ "Source": "fix", "Target": "master", "Link": "https://gitlab.com/gitlab-org/testme/merge_requests/1", + "Draft": false, "Closed": true, "Merged": false, "Author": { diff --git a/scm/driver/gitlab/testdata/webhooks/pull_request_review_ready.json.golden b/scm/driver/gitlab/testdata/webhooks/pull_request_review_ready.json.golden index c7521303..059b6bbd 100644 --- a/scm/driver/gitlab/testdata/webhooks/pull_request_review_ready.json.golden +++ b/scm/driver/gitlab/testdata/webhooks/pull_request_review_ready.json.golden @@ -23,6 +23,7 @@ "Target": "main", "Fork": "Meet Rathod/meet", "Link": "https://gitlab.com/rathod.meetsatish/meet/-/merge_requests/3", + "Draft": true, "Closed": false, "Merged": false, "Author": { diff --git a/scm/driver/gitlab/webhook.go b/scm/driver/gitlab/webhook.go index 2cc785fb..30992e61 100644 --- a/scm/driver/gitlab/webhook.go +++ b/scm/driver/gitlab/webhook.go @@ -238,6 +238,7 @@ func convertCommentHook(src *commentHook) (*scm.IssueCommentHook, error) { Source: src.MergeRequest.SourceBranch, Target: src.MergeRequest.TargetBranch, Link: src.MergeRequest.URL, + Draft: src.MergeRequest.WorkInProgress, Closed: src.MergeRequest.State != "opened", Merged: src.MergeRequest.State == "merged", Author: *convertUser(&src.User), @@ -359,6 +360,7 @@ func convertPullRequestHook(src *pullRequestHook) *scm.PullRequestHook { Target: src.ObjectAttributes.TargetBranch, Fork: fork, Link: src.ObjectAttributes.URL, + Draft: src.ObjectAttributes.WorkInProgress, Closed: src.ObjectAttributes.State != "opened", Merged: src.ObjectAttributes.State == "merged", // Created : src.ObjectAttributes.CreatedAt, diff --git a/scm/pr.go b/scm/pr.go index 1fd2e5a5..1e9a7494 100644 --- a/scm/pr.go +++ b/scm/pr.go @@ -22,6 +22,7 @@ type ( Fork string Link string Diff string + Draft bool Closed bool Merged bool Merge string