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

feat(config): Allow overriding of remote API URL #896

Merged
merged 10 commits into from
Nov 19, 2024
Merged

Conversation

pauliyobo
Copy link
Contributor

Description

This PR aims to simplify the configuration of remote API URL for a particular remote by adding the option in the remote section.

Motivation and Context

Up until now, an environment variable needed to be set such as GITLAB_API_URL_ENV
fixes #704

How Has This Been Tested?

I only ran the existing tests, as I was unsure of where tests for this feature would have to be added. If there's a particular place I should consider adding them in, let me know.

Screenshots / Logs (if applicable)

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • 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:

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

Questions

The change introduces a refactor which I wouldn't consider a breaking change. The functionality is preserved but essentially the api_url() method in the RemoteClient has now a default implementation which leverages on the constants API_URL and API_URL_ENV which allows us to just implements the various traits by setting the appropriate constants without duplicating the code.
I have two questions related to this:

  • Is this a welcomed refactor?
  • In the following code:

https://github.com/pauliyobo/git-cliff/blob/c2398dc452b0f8c3aef1a3f7db8c6748a6de7f24/git-cliff-core/src/repo.rs#L397-L444

I wasn't sure of whether the returned upstream remote should also have its proper api_url set. Is that the case? I have left it on None for now.

@pauliyobo pauliyobo requested a review from orhun as a code owner September 30, 2024 07:29
Copy link

welcome bot commented Sep 30, 2024

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

@codecov-commenter
Copy link

codecov-commenter commented Sep 30, 2024

Codecov Report

Attention: Patch coverage is 25.00000% with 6 lines in your changes missing coverage. Please review.

Project coverage is 43.35%. Comparing base (d0848ff) to head (e80ca3e).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
git-cliff-core/src/remote/mod.rs 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #896      +/-   ##
==========================================
+ Coverage   43.14%   43.35%   +0.21%     
==========================================
  Files          21       21              
  Lines        1718     1712       -6     
==========================================
+ Hits          741      742       +1     
+ Misses        977      970       -7     
Flag Coverage Δ
unit-tests 43.35% <25.00%> (+0.21%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@orhun
Copy link
Owner

orhun commented Oct 5, 2024

Hello, thanks for the PR! I pushed some nitpicks & refactored the remote handling a bit not to keep you waiting any longer :) Now, when it comes to your questions:

I only ran the existing tests, as I was unsure of where tests for this feature would have to be added. If there's a particular place I should consider adding them in, let me know.

Yup, we should add a fixture test to make sure this is working. I would suggest copying test-gitlab-integration and using a project hosted on a custom GitLab instance (e.g. arch-repro-status.

Also, I couldn't see the part where we override the remote URL with the value taken from config yet. We should probably do that as well.

Is this a welcomed refactor?

Yup, I think it's good :)

I wasn't sure of whether the returned upstream remote should also have its proper api_url set.

Not really, this should be left like this for now.


Sorry for the delayed review, would you be able to address these sometime? 😊

@pauliyobo
Copy link
Contributor Author

Hello, thanks for the feedback.
I'm a bit busy this week, will try to get something out by the next.
Thank you.

Copy link
Owner

@orhun orhun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

@orhun orhun merged commit 6d86e2c into orhun:main Nov 19, 2024
63 of 67 checks passed
Copy link

welcome bot commented Nov 19, 2024

Congrats on merging your first pull request! ⛰️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support overriding the API URL in config
3 participants