Skip to content

fix(updating): run tasks in Git repository with subproject's Git config#2541

Open
sisp wants to merge 1 commit into
masterfrom
fix/run-tasks-with-subproject-git-config
Open

fix(updating): run tasks in Git repository with subproject's Git config#2541
sisp wants to merge 1 commit into
masterfrom
fix/run-tasks-with-subproject-git-config

Conversation

@sisp

@sisp sisp commented Mar 10, 2026

Copy link
Copy Markdown
Member

I've fixed the update algorithm to Git-initialize the temporary locations wherein the fresh copies of old and new template versions are generated such that tasks are run inside Git repositories. Also, these temporary Git repositories now reuse the subproject's Git config, so settings like Git remotes are accessible by tasks and custom Jinja extensions.

I think it's a valid assumption that temporary locations are Git repositories because the update algorithm requires Git to be installed and the subproject to be a Git repository, too. Hence, it may come as a surprise to template authors when tasks or Jinja extensions are run in the temporary locations, managed by the update algorithm, that aren't Git repositories. After all, having temporary locations is an implementation detail of the update algorithm, I think we should avoid leaking internals to template authors as much as possible.

Just to be sure I'm not missing anything, would the @copier-org/maintainers mind double-checking this idea?

Closes #2478.

@codecov

codecov Bot commented Mar 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.55%. Comparing base (b80196e) to head (f8a58e6).

❗ There is a different number of reports uploaded between BASE (b80196e) and HEAD (f8a58e6). Click for more details.

HEAD has 10 uploads less than BASE
Flag BASE (b80196e) HEAD (f8a58e6)
unittests 15 5
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #2541       +/-   ##
===========================================
- Coverage   97.23%   82.55%   -14.69%     
===========================================
  Files          60       60               
  Lines        7282     7296       +14     
===========================================
- Hits         7081     6023     -1058     
- Misses        201     1273     +1072     
Flag Coverage Δ
unittests 82.55% <100.00%> (-14.69%) ⬇️

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

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread tests/test_vcs.py
dst_path=tmp_path,
defaults=True,
unsafe=True,
skip_tasks=True,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I decided to disable tasks here (and also below) because the generated project of this archived template uses a pre-commit hook from https://gitlab.com/pycqa/flake8 which doesn't exist anymore. When trying to clone a non-existing Git repository on gitlab.com, Git prompts for credentials which blocks the test case. The pre-commit hooks are installed via a task and thus executed on git commit run internally by the update algorithm. Before the changes of this PR, there was no problem because the temporary locations managed by the update algorithm were no Git repositories at the time of project generation, so the pre-commit hooks were not installed by the task.

@sisp sisp requested a review from pawamoy April 2, 2026 07:54
@Gara-Dorta

Copy link
Copy Markdown

I don't mean to create noise here but is this PR abandoned? I'm also hit by the same issue as #2478 in python-package-template#39

@sisp sisp force-pushed the fix/run-tasks-with-subproject-git-config branch from eb7a9e2 to f8a58e6 Compare June 12, 2026 09:13
@sisp

sisp commented Jun 12, 2026

Copy link
Copy Markdown
Member Author

Thanks for the reminder, @Gara-Dorta! 👍 No, it isn't abandoned, just never got merged because I was hoping for a sanity check. But I believe this should be a safe change after re-thinking it again. I just resolved a merge conflict, will merge once CI passes.

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.

Tasks with copier update fail if they need a Git repo

2 participants