git-cliff icon indicating copy to clipboard operation
git-cliff copied to clipboard

feat(gitlab): Add gitlab support

Open dark0dave opened this issue 4 months ago • 13 comments

Description

Adding Gitlab support

Motivation and Context

Much like we support github we should also support gitlab

How Has This Been Tested?

Its still a work in progress

Screenshots / Logs (if applicable)

Types of Changes

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)
  • [ ] Documentation (no code change)
  • [ ] Refactor (refactoring production code)
  • [ ] Other

Checklist:

  • [x] My code follows the code style of this project.
  • [ ] I have updated the documentation accordingly.
  • [x] I have formatted the code with rustfmt.
  • [x] I checked the lints with clippy.
  • [x] I have added tests to cover my changes.
  • [x] All new and existing tests passed.

dark0dave avatar Apr 14 '24 10:04 dark0dave

Thanks for opening this pull request! Please check out our contributing guidelines! ⛰️

welcome[bot] avatar Apr 14 '24 10:04 welcome[bot]

Codecov Report

Attention: Patch coverage is 24.21053% with 144 lines in your changes are missing coverage. Please review.

Project coverage is 38.96%. Comparing base (d53b905) to head (6cb0a54). Report is 11 commits behind head on main.

Files Patch % Lines
git-cliff-core/src/gitlab.rs 0.00% 90 Missing :warning:
git-cliff-core/src/changelog.rs 30.00% 28 Missing :warning:
git-cliff/src/lib.rs 0.00% 14 Missing :warning:
git-cliff-core/src/release.rs 81.09% 7 Missing :warning:
git-cliff/src/logger.rs 0.00% 4 Missing :warning:
git-cliff-core/src/commit.rs 50.00% 1 Missing :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #612      +/-   ##
==========================================
- Coverage   41.52%   38.96%   -2.56%     
==========================================
  Files          15       16       +1     
  Lines        1072     1258     +186     
==========================================
+ Hits          445      490      +45     
- Misses        627      768     +141     
Flag Coverage Δ
unit-tests 38.96% <24.22%> (-2.56%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Apr 14 '24 10:04 codecov-commenter

@orhun I have tried to stick as close as I can to your github integration. Fortunately the gitlab api works in a very similar way to the github one.

Please tell me if you think this is the right approach.

dark0dave avatar Apr 14 '24 15:04 dark0dave

Wow, this is great! Thanks for making it happen <3

Is it actually functional now? Can we add some tests (fixtures) to verify the behavior?

orhun avatar Apr 14 '24 18:04 orhun

Wow, this is great! Thanks for making it happen <3

Is it actually functional now? Can we add some tests (fixtures) to verify the behavior?

Yes I will add some tests in a bit!

Glad to see you happy for it!

dark0dave avatar Apr 14 '24 18:04 dark0dave

@orhun I have a working integration test :tada:

Some slight bugs remain but we are almost there

dark0dave avatar Apr 14 '24 21:04 dark0dave

@orhun this is now complete, with tests and integration tests. I would appreciate it if you could look over it.

dark0dave avatar Apr 16 '24 20:04 dark0dave

@orhun let me know if you need anything more for me to merge this. Thank you!

dark0dave avatar Apr 20 '24 12:04 dark0dave

Thank you @dark0dave - this is pretty exciting. I will add a review soon!

orhun avatar Apr 20 '24 14:04 orhun

@orhun I have significantly reduced the fields in the gitlab merge request struct as requested.

If you would kindly take another look, thank you!

dark0dave avatar Apr 27 '24 11:04 dark0dave

Hey, all looks good! One thing that I want to do before moving on with this is refactoring the code to avoid duplications between GitHub and GitLab integration. This will also make it easier to add other remotes in the future.

My plan is to introduce a trait (maybe called GitRemote or RemoteCommit, RemotePullRequest) then implement it over GitHub and GitLab types. Then we can move over these modules to remote/ and use generic methods to handle things. I'm talking off the top of my head now but that's roughly how it should be done I think.

I can get to this this week, but let me know what you think of it and possibly want to take a stab! Sorry it took a bit of time to get this PR in - due to the fact that it was a great surprise 😄

orhun avatar Apr 28 '24 02:04 orhun

Hey, all looks good! One thing that I want to do before moving on with this is refactoring the code to avoid duplications between GitHub and GitLab integration. This will also make it easier to add other remotes in the future.

My plan is to introduce a trait (maybe called GitRemote or RemoteCommit, RemotePullRequest) then implement it over GitHub and GitLab types. Then we can move over these modules to remote/ and use generic methods to handle things. I'm talking off the top of my head now but that's roughly how it should be done I think.

I can get to this this week, but let me know what you think of it and possibly want to take a stab! Sorry it took a bit of time to get this PR in - due to the fact that it was a great surprise 😄

Yeah I was thinking about that, the whole time I was doing this. It would make it easier for us to support more providers in the future. I was thinking we could do it as an improvement (ie annother PR). But happy to do it to this one if you think thats appropriate.

dark0dave avatar Apr 29 '24 07:04 dark0dave