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

[Bug][gitlab] Not fetching correctly squashed commits from merge requests #5486

Closed
3 tasks done
Marco-De-Stefani opened this issue Jun 14, 2023 · 4 comments · Fixed by #5501
Closed
3 tasks done

[Bug][gitlab] Not fetching correctly squashed commits from merge requests #5486

Marco-De-Stefani opened this issue Jun 14, 2023 · 4 comments · Fixed by #5501
Assignees
Labels
type/bug This issue is a bug

Comments

@Marco-De-Stefani
Copy link
Contributor

Search before asking

  • I had searched in the issues and found no similar issues.

What happened

The fetching of the merge request information from GitLab APIs is not completely correct because the option "squash on merge" of GitLab is not managed correctly.
To be more specific when a MR is squashed the related commit sha is not reported inside the field "merge_commit_sha" that we are fetching from GitLab APIs but is instead inside the "squash_commit_sha" field. The information about the squashing option enabled or disabled is inside the "squash" field.

Gitlab docs: https://docs.gitlab.com/ee/api/merge_requests.html#response

What do you expect to happen

I would have expected to have the "merge_commit_sha" field in the "pull_requests" table be populated to proceed with the DORA metrics validation.

How to reproduce

  • Have a working version of DevLake
  • Integrate it with a GitLab project
  • In the integrated Gitlab project set as "Required" the squash option (under Settings -> Merge Request -> Squash commits when merging)
  • Create a Merge request in the project and merge it

Anything else

No response

Version

v0.17.0

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

@Marco-De-Stefani Marco-De-Stefani added the type/bug This issue is a bug label Jun 14, 2023
@klesh
Copy link
Contributor

klesh commented Jun 15, 2023

I see, what is the solution in your mind? Should we add a new column or convert the squash_commit_sha instead of merge_commit_sha?

@Marco-De-Stefani
Copy link
Contributor Author

I've tried to convert the squash_commit_sha inside the merge_commit_sha field and it looks like it's working fine.
Just to avoid the creation of other bugs, let me test something more regarding that and I'll provide a PR

(I realized this morning that in some strange cases, GitLab is returning null to both of the fields, so maybe it's a GitLab bug)

@klesh
Copy link
Contributor

klesh commented Jun 15, 2023

@Marco-De-Stefani I talked to @liangjingyang and he contributed some very valuable information:
Accord to the comment from the gitlab official repo, not only merge_commit_sha might be null, but also squash_commit_sha when using fast-forward without squash.
So, we may need to do another fallback to the diff_head_sha to fully address the problem.

@Marco-De-Stefani
Copy link
Contributor Author

@klesh I opened a PR, if you think that something is not right, feel free to contact me on Slack

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug This issue is a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants