Open frantic1048 opened 11 months ago
@frantic1048 — I’m not sure DangerJS can fix this right? Since the upstream issue is 4 years old?…
What would you like to do here?
@fbartho Here are 2 ways I found to workaround it, but both of them have their own drawbacks. I'm currently using the second workaround to perform checks around parent_ids
.
Use GitLab Commits API
Retrieve parent_ids
via GET /projects/:id/repository/commits/:sha
, since this API is not suffering from the same issue. However, using this API may lead to lots of API calls when there are many commits in the merge request.
e.g. https://gitlab.com/api/v4/projects/53011396/repository/commits/f1c6ae6e
Use git CLI
Use git show -s --pretty=format:%p <commit>
to retrieve parent_ids
. This more efficient than the first workaround, but it requires a local git repository.
To ensure essential git history is available, we may need to run git fetch $CI_COMMIT_REF_NAME
first.
Because of the drawbacks, I'm not promoting any of the workarounds into danger-js. Just sharing my findings here in case anyone else is facing the same issue.
For danger-js, I think it's better to add some warning messages(through comments on the type definition) about parent_ids
field in the merge request payload, so that users can be aware of the issue.
Describe the bug
To Reproduce
This MR compares results from danger's
parent_ids
and git CLI(the expected result).https://gitlab.com/frantic1048/danger-empty-parent-ids/-/merge_requests/1
Expected behavior
A commit's
parent_ids
should contain all parent ids.Your Environment
Additional context
This is actually an upstream issue of GitLab: Commit parent IDs list is empty in some REST API's.
To ensure a smoother experience, we may implement a workaround in danger.