Skip to content

Commit

Permalink
Merge pull request #1073 from morucci/merged_commit_sha
Browse files Browse the repository at this point in the history
crawler - github - index the mergeCommit's sha
  • Loading branch information
mergify[bot] authored Oct 30, 2023
2 parents 159f027 + c5e4148 commit 7915520
Show file tree
Hide file tree
Showing 13 changed files with 249 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ All notable changes to this project will be documented in this file.

- [crawler] Enable usage of the GitHub user PRs crawler via the Monocle config.
- [cli] Add a Janitor command to reset the commit date of a crawler
- [crawler] Github crawler gathers the `mergeCommit`'s SHA. `Change` and `ChangeEvent*` objects
get a new field `merged_commit_sha` in the database.

### Changed

Expand Down
179 changes: 179 additions & 0 deletions codegen/Monocle/Protob/Change.hs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions schemas/monocle/protob/change.proto
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ message Change {
oneof optional_self_merged {
bool self_merged = 31;
}
oneof optional_merged_commit_sha {
string merged_commit_sha = 32;
}
}

message ChangeCreatedEvent {}
Expand Down Expand Up @@ -127,4 +130,7 @@ message ChangeEvent {
int32 duration = 23;
}
bool draft = 24;
oneof optional_merged_commit_sha {
string merged_commit_sha = 25;
}
}
2 changes: 2 additions & 0 deletions src/Lentille/Gerrit.hs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ streamChange' env identCB serverUrl query prefixM = go 0
changeEventType = Just eType
changeEventOptionalDuration = swapDuration <$> changeOptionalDuration
changeEventDraft = changeDraft
changeEventOptionalMergedCommitSha = Nothing
in ChangePB.ChangeEvent {..}
toChangeCreatedEvent =
baseEvent (ChangePB.ChangeEventTypeChangeCreated ChangePB.ChangeCreatedEvent) $ "CCE" <> changeId
Expand Down Expand Up @@ -343,6 +344,7 @@ streamChange' env identCB serverUrl query prefixM = go 0
if status == MERGED
then ChangePB.ChangeOptionalMergedByMergedBy <$> merger
else Nothing
changeOptionalMergedCommitSha = Nothing
changeBranch = from branch
changeTargetBranch = from branch
changeCreatedAt = Just $ toTimestamp created
Expand Down
4 changes: 4 additions & 0 deletions src/Lentille/GitHub/GraphQLFragments.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ fragmentPRData =
bodyText
state
reviewDecision
mergeCommit {
__typename
mergedCommitOid: oid
}
number
mergeable
isDraft
Expand Down
4 changes: 4 additions & 0 deletions src/Lentille/GitHub/PullRequests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ transformResponse host identCB result = do
getPRMergedBy :: GetProjectPullRequestsRepositoryPullRequestsNodesMergedBy -> Text
getPRMergedBy (GetProjectPullRequestsRepositoryPullRequestsNodesMergedBy _ login) = login

getPRMergedCommitSHA :: GetProjectPullRequestsRepositoryPullRequestsNodesMergeCommit -> LText
getPRMergedCommitSHA (GetProjectPullRequestsRepositoryPullRequestsNodesMergeCommit _ sha) = from $ getSHA sha

toLabels :: GetProjectPullRequestsRepositoryPullRequestsNodesLabels -> [Text]
toLabels (GetProjectPullRequestsRepositoryPullRequestsNodesLabels nodes) =
toLabel <$> catMaybes (fromMaybe [] nodes)
Expand Down Expand Up @@ -250,6 +253,7 @@ transformResponse host identCB result = do
, changeRepositoryShortname = from . snd $ repoOwnerName repository
, changeAuthor = Just $ maybe getGhostIdent (getIdent . getPRAuthor) author
, changeOptionalMergedBy = ChangeOptionalMergedByMergedBy . getIdent . getPRMergedBy <$> mergedBy
, changeOptionalMergedCommitSha = ChangeOptionalMergedCommitShaMergedCommitSha . getPRMergedCommitSHA <$> mergeCommit
, changeBranch = from headRefName
, changeTargetBranch = from baseRefName
, changeCreatedAt = Just $ from createdAt
Expand Down
Loading

0 comments on commit 7915520

Please sign in to comment.