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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

pauliyobo
Copy link

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.

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 0% with 4 lines in your changes missing coverage. Please review.

Project coverage is 40.23%. Comparing base (bfe9beb) to head (a6e1262).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
git-cliff-core/src/remote/mod.rs 0.00% 3 Missing ⚠️
git-cliff-core/src/repo.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #896      +/-   ##
==========================================
+ Coverage   40.04%   40.23%   +0.20%     
==========================================
  Files          21       21              
  Lines        1671     1663       -8     
==========================================
  Hits          669      669              
+ Misses       1002      994       -8     
Flag Coverage Δ
unit-tests 40.23% <0.00%> (+0.20%) ⬆️

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.

@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
Author

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

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