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(settings): add user settings support with defaults values and trusts #1940

Merged
merged 2 commits into from
Jan 29, 2025

Conversation

noirbizarre
Copy link
Contributor

Hello 👋🏼

This PR adds support for user settings with initial support for:

Settings are stored in <CONFIG_ROOT>/settings.yml where <CONFIG_ROOT> is the
standard configuration directory for your platform:

This location can be overridden by setting the COPIER_SETTINGS environment variable.

The settings look like:

defaults:
    user_name: "John Doe"
    user_email: [email protected]
trust:
    - https://github.com/account/template.git
    - https://github.com/org/
    - ~/templates/

Copy link

codecov bot commented Jan 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.05%. Comparing base (57439e5) to head (fbd4021).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1940      +/-   ##
==========================================
+ Coverage   97.85%   98.05%   +0.20%     
==========================================
  Files          51       53       +2     
  Lines        5404     5511     +107     
==========================================
+ Hits         5288     5404     +116     
+ Misses        116      107       -9     
Flag Coverage Δ
unittests 98.05% <100.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.

Copy link
Contributor

@pawamoy pawamoy left a comment

Choose a reason for hiding this comment

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

Very nice! I like the prefix matching approach for trusted repositories, it's simple and it makes sense.

copier/main.py Outdated Show resolved Hide resolved
copier/settings.py Show resolved Hide resolved
copier/settings.py Show resolved Hide resolved
docs/configuring.md Outdated Show resolved Hide resolved
docs/settings.md Outdated Show resolved Hide resolved
tests/test_config.py Outdated Show resolved Hide resolved
tests/test_settings.py Outdated Show resolved Hide resolved
tests/test_settings.py Outdated Show resolved Hide resolved
tests/test_settings.py Outdated Show resolved Hide resolved
tests/test_settings.py Outdated Show resolved Hide resolved
Copy link
Member

@sisp sisp left a comment

Choose a reason for hiding this comment

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

Fantastic work, @noirbizarre! 🎉 Thanks for working on and contributing these valuable features! 🙏

I have a few minor remarks. And would you mind fixing the formatting errors in the corresponding commit and drop the auto-fix commit? We'll likely want to rebase-merge this PR to keep the two feature commits, so the auto-fix commit would only add some noise to the Git history.

docs/settings.md Outdated Show resolved Hide resolved
docs/settings.md Outdated Show resolved Hide resolved
docs/settings.md Outdated Show resolved Hide resolved
tests/test_config.py Outdated Show resolved Hide resolved
tests/test_settings.py Outdated Show resolved Hide resolved
@noirbizarre
Copy link
Contributor Author

You're welcome ! 🙏🏼
I take the suggestion commit, and I'll rebase properly everything, that was plan from the start 😉

@noirbizarre noirbizarre force-pushed the feat/settings branch 2 times, most recently from ac3b856 to f8a881c Compare January 20, 2025 22:15
Copy link
Member

@sisp sisp left a comment

Choose a reason for hiding this comment

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

Just a few more comments after another review iteration. 🙂

copier/errors.py Outdated Show resolved Hide resolved
copier/settings.py Show resolved Hide resolved
docs/settings.md Show resolved Hide resolved
@noirbizarre noirbizarre force-pushed the feat/settings branch 2 times, most recently from 211835d to c07fa2f Compare January 24, 2025 22:35
@noirbizarre
Copy link
Contributor Author

PR rebased to solve lock conflict

Copy link
Contributor

@pawamoy pawamoy left a comment

Choose a reason for hiding this comment

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

👌

Copy link
Member

@sisp sisp left a comment

Choose a reason for hiding this comment

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

Just some final polishing requests from my side. With two independent commits in a PR, we need to be extra careful to associate a change with the right commit. For instance, we have a formatting change in the first commit and the inverse change in the second commit, so there's no diff for this section under Files changed but there is a diff in each commit.

tests/test_settings.py Show resolved Hide resolved
copier/settings.py Show resolved Hide resolved
copier/main.py Outdated Show resolved Hide resolved
copier/settings.py Outdated Show resolved Hide resolved
@noirbizarre
Copy link
Contributor Author

Updated 👍🏼
Sorry, the direnv+nix seems broken on my setup, and it was still having an older flake8+black stack in pre-commit (which applied the faulty formatting).
However, the poe lint task seems OK, I'll do with it 👍🏼

poetry.lock Outdated Show resolved Hide resolved
@noirbizarre noirbizarre force-pushed the feat/settings branch 2 times, most recently from df246e5 to 6547b51 Compare January 29, 2025 01:28
poetry.lock Outdated Show resolved Hide resolved
Copy link
Member

@sisp sisp left a comment

Choose a reason for hiding this comment

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

Thank you very much again for this great PR and your patience with the review cycles, @noirbizarre! 🙏

I think we can merge this PR, only one tiny cosmetic detail I just stumbled over 🫣: Could you fix the second commit message?

-feat(settings): allows to defined some trusted repositories or prefixes
+feat(settings): allow to define some trusted repositories or prefixes

@noirbizarre
Copy link
Contributor Author

No problem, there it is, fixed. (Sorry, I do many typos currently 😅)

@sisp
Copy link
Member

sisp commented Jan 29, 2025

No worries, thanks again for your efforts and patience!

@sisp sisp enabled auto-merge (rebase) January 29, 2025 18:34
@sisp sisp merged commit 71358ed into copier-org:master Jan 29, 2025
22 checks passed
@noirbizarre noirbizarre deleted the feat/settings branch January 29, 2025 19:07
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.

3 participants