Skip to content

Commit 2c48333

Browse files
committed
Add mergeable for PRs
Failing a PR because of a merge conflict/bad build/test failure, should be addressed properly by the PR owner.
1 parent 3657359 commit 2c48333

File tree

8 files changed

+27
-5
lines changed

8 files changed

+27
-5
lines changed

internal/github/github.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ type prSearchResultGraphQl struct {
4040
}
4141
}
4242
ReviewDecision string
43+
Mergeable bool
4344
UpdatedAt string
4445
Author struct {
4546
Login string
@@ -264,6 +265,7 @@ func QueryGithub(token string, username string, logger *slog.Logger) ([]types.Vi
264265
RepoOwner: pr.Repository.Owner.Login,
265266
RepoUrl: pr.Repository.Url,
266267
IsDraft: pr.IsDraft,
268+
Mergeable: pr.Mergeable,
267269
LastUpdated: updatedAt,
268270
LastPrCommenter: lastPrCommenter,
269271
ThreadsActionable: threadsActionable,
@@ -362,6 +364,7 @@ func querySearchPrsInvolvingUser(username string) string {
362364
}
363365
}
364366
reviewDecision
367+
mergeable
365368
updatedAt
366369
author {
367370
login

internal/points/points.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ func StandardPrPoints(pr types.ViewPr, username string) *Points {
5757
// at it
5858
points.Add(10, "You should add reviewers")
5959
}
60+
61+
if !pr.Mergeable {
62+
points.Add(150, "Some checks failed (failed build/test, merge conflicts, github actions, etc.)")
63+
}
6064
} else {
6165
// someone else's pr, or our but the username is not set
6266
if pr.ReviewStatus == "APPROVED" {
@@ -92,6 +96,10 @@ func StandardPrPoints(pr types.ViewPr, username string) *Points {
9296
case diff > 300:
9397
points.Add(10, fmt.Sprintf("PR is bigish, %d loc changed is >300", diff))
9498
}
99+
100+
if !pr.Mergeable {
101+
points.Remove(150, "Some checks failed (failed build/test, merge conflicts, github actions, etc.)")
102+
}
95103
}
96104

97105
if pr.ThreadsActionable > 0 {

internal/storage/models.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/storage/query.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ insert into prs (
1111
repo_owner,
1212
repo_url,
1313
is_draft,
14+
mergeable,
1415
last_updated,
1516
last_pr_commenter,
1617
threads_actionable,
@@ -20,7 +21,7 @@ insert into prs (
2021
review_requested_from_users,
2122
buried
2223
) values (
23-
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
24+
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
2425
) returning *;
2526

2627
-- name: DeletePrs :exec

internal/storage/query.sql.go

Lines changed: 10 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/storage/schema.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ create table if not exists prs (
77
repo_owner text not null,
88
repo_url text not null,
99
is_draft boolean not null,
10+
mergeable boolean not null,
1011
last_updated text not null,
1112
last_pr_commenter text not null,
1213
threads_actionable integer not null,

internal/storage/storage.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ func (s *Storage) StoreRepoPrs(orderedPrs []types.ViewPr) error {
117117
RepoName: pr.RepoName,
118118
RepoOwner: pr.RepoOwner,
119119
RepoUrl: pr.RepoUrl,
120+
Mergeable: pr.Mergeable,
120121
IsDraft: pr.IsDraft,
121122
LastUpdated: pr.LastUpdated.Format(time.RFC3339),
122123
LastPrCommenter: pr.LastPrCommenter,

internal/types/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type ViewPr struct {
1717
RepoOwner string
1818
RepoUrl string
1919
IsDraft bool
20+
Mergeable bool
2021
LastUpdated time.Time
2122
LastPrCommenter string
2223
ThreadsActionable int

0 commit comments

Comments
 (0)