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

crawler - github - index the mergeCommit's sha #1073

Merged
merged 3 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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
Loading