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

fix: Missing passing of skip_tasks flag #1688

Merged
merged 5 commits into from
Jul 3, 2024

Conversation

arnaubt
Copy link
Contributor

@arnaubt arnaubt commented Jul 2, 2024

Couldn't get the --skip-flags option working until I passed the option to the worker.

Copy link

codecov bot commented Jul 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.72%. Comparing base (3f89b71) to head (9dba293).
Report is 63 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1688      +/-   ##
==========================================
+ Coverage   97.59%   97.72%   +0.12%     
==========================================
  Files          49       49              
  Lines        4993     5002       +9     
==========================================
+ Hits         4873     4888      +15     
+ Misses        120      114       -6     
Flag Coverage Δ
unittests 97.72% <100.00%> (+0.12%) ⬆️

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
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.

Thanks for discovering and fixing this bug, @arnaubt! 🙏 LGTM! 🎉

Just one request. It would be great to have a test, e.g. similar to:

@pytest.mark.parametrize("unsafe", [False, True])
def test_copy_cli(
tmp_path_factory: pytest.TempPathFactory,
capsys: pytest.CaptureFixture[str],
unsafe: bool,
) -> None:
src, dst = map(tmp_path_factory.mktemp, ["src", "dst"])
build_file_tree(
{(src / "copier.yaml"): yaml.safe_dump({"_tasks": ["touch task.txt"]})}
)
_, retcode = CopierApp.run(
["copier", "copy", *(["--UNSAFE"] if unsafe else []), str(src), str(dst)],
exit=False,
)
if unsafe:
assert retcode == 0
else:
assert retcode == 4
_, err = capsys.readouterr()
assert "Template uses potentially unsafe feature: tasks." in err

Would you mind adding one?

@arnaubt
Copy link
Contributor Author

arnaubt commented Jul 3, 2024

@sisp Sure enough, test added! Let me know if it's good enough.

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.

LGTM, just some minor requests. Sorry that I was a bit imprecise, I was thinking to add the test in tests/test_tasks.py perhaps below

def test_copy_skip_tasks(template_path: str, tmp_path: Path) -> None:
copier.run_copy(
template_path,
tmp_path,
quiet=True,
defaults=True,
overwrite=True,
skip_tasks=True,
)
assert not (tmp_path / "hello").exists()
assert not (tmp_path / "hello").is_dir()
assert not (tmp_path / "hello" / "world").exists()
assert not (tmp_path / "bye").is_file()
assert not (tmp_path / "pyfile").is_file()

Could you please move it there?

tests/test_unsafe.py Outdated Show resolved Hide resolved
tests/test_unsafe.py Outdated Show resolved Hide resolved
@arnaubt
Copy link
Contributor Author

arnaubt commented Jul 3, 2024

Test moved and suggestions applied, thanks!

tests/test_tasks.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.

LGTM! 🎉 Thanks again, @arnaubt! 🙏

@sisp sisp enabled auto-merge (squash) July 3, 2024 13:19
@sisp sisp merged commit 1035e94 into copier-org:master Jul 3, 2024
21 of 22 checks passed
@arnaubt arnaubt deleted the fix-skip-tasks-flag branch July 3, 2024 13:30
@arnaubt
Copy link
Contributor Author

arnaubt commented Jul 3, 2024

@sisp Great! When do you expect this to be released?

@sisp
Copy link
Member

sisp commented Jul 3, 2024

@yajo is creating releases for us. Would you be open to and available for making a quick patch release, @yajo?

@yajo
Copy link
Member

yajo commented Jul 3, 2024

Released!
https://github.com/copier-org/copier/releases/tag/v9.3.1

@sisp
Copy link
Member

sisp commented Jul 3, 2024

Thank you very much! 🙏

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