Skip to content

Commit

Permalink
Add argument to list the train of PRs
Browse files Browse the repository at this point in the history
  • Loading branch information
rudymatela committed Aug 2, 2022
1 parent 1341dc6 commit 5f6ac09
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
7 changes: 5 additions & 2 deletions src/Logic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -756,8 +756,11 @@ describeStatus prId pr state = case Pr.classifyPullRequest pr of
0 -> format "Pull request approved for {} by @{}, rebasing now." [approvalCommand, approvedBy]
1 -> format "Pull request approved for {} by @{}, waiting for rebase behind one pull request." [approvalCommand, approvedBy]
n -> format "Pull request approved for {} by @{}, waiting for rebase behind {} pull requests." (approvalCommand, approvedBy, n)
PrStatusBuildPending -> let Sha sha = fromJust $ getIntegrationSha pr
in Text.concat ["Rebased as ", sha, ", waiting for CI …"]
PrStatusBuildPending train -> let Sha sha = fromJust $ getIntegrationSha pr
behind = case train of [] -> ""
_ -> "behind ..." -- TODO: intercalate PR ids here
in Text.concat ["Rebased as ", sha, behind, ", waiting for CI …"]

PrStatusBuildStarted url -> Text.concat ["[CI job](", url, ") started."]
PrStatusIntegrated -> "The build succeeded."
PrStatusIncorrectBaseBranch -> "Merge rejected: the target branch must be the integration branch."
Expand Down
22 changes: 11 additions & 11 deletions src/Project.hs
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,16 @@ data IntegrationStatus
deriving (Eq, Show, Generic)

data PullRequestStatus
= PrStatusAwaitingApproval -- New, awaiting review.
| PrStatusApproved -- Approved, but not yet integrated or built.
| PrStatusBuildPending -- Integrated, and build pending or in progress.
| PrStatusBuildStarted Text -- Integrated, and build pending or in progress.
| PrStatusIntegrated -- Integrated, build passed, merged into target branch.
| PrStatusIncorrectBaseBranch -- ^ Integration branch not being valid.
| PrStatusWrongFixups -- Failed to integrate due to the presence of orphan fixup commits.
| PrStatusEmptyRebase -- Rebase was empty (changes already in the target branch?)
| PrStatusFailedConflict -- Failed to integrate due to merge conflict.
| PrStatusFailedBuild (Maybe Text) -- Integrated, but the build failed. Field should contain the URL to a page explaining the build failure.
= PrStatusAwaitingApproval -- New, awaiting review.
| PrStatusApproved -- Approved, but not yet integrated or built.
| PrStatusBuildPending [PullRequestId] -- Integrated, and build pending or in progress.
| PrStatusBuildStarted Text -- Integrated, and build pending or in progress.
| PrStatusIntegrated -- Integrated, build passed, merged into target branch.
| PrStatusIncorrectBaseBranch -- ^ Integration branch not being valid.
| PrStatusWrongFixups -- Failed to integrate due to the presence of orphan fixup commits.
| PrStatusEmptyRebase -- Rebase was empty (changes already in the target branch?)
| PrStatusFailedConflict -- Failed to integrate due to merge conflict.
| PrStatusFailedBuild (Maybe Text) -- Integrated, but the build failed. Field should contain the URL to a page explaining the build failure.
deriving (Eq)

-- A PR can be approved to be merged with "<prefix> merge", or it can be
Expand Down Expand Up @@ -296,7 +296,7 @@ classifyPullRequest pr = case approval pr of
Conflicted _ EmptyRebase -> PrStatusEmptyRebase
Conflicted _ _ -> PrStatusFailedConflict
Integrated _ buildStatus -> case buildStatus of
BuildPending -> PrStatusBuildPending
BuildPending -> PrStatusBuildPending []
BuildStarted url -> PrStatusBuildStarted url
BuildSucceeded -> PrStatusIntegrated
BuildFailed url -> PrStatusFailedBuild url
Expand Down
2 changes: 1 addition & 1 deletion src/WebInterface.hs
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,6 @@ prFailed (Project.PrStatusFailedBuild _) = True
prFailed _ = False

prPending :: Project.PullRequestStatus -> Bool
prPending Project.PrStatusBuildPending = True
prPending (Project.PrStatusBuildPending _) = True
prPending (Project.PrStatusBuildStarted _) = True
prPending _ = False

0 comments on commit 5f6ac09

Please sign in to comment.