copier icon indicating copy to clipboard operation
copier copied to clipboard

Can't update git submodules

Open twsl opened this issue 1 year ago • 4 comments
trafficstars

Describe the problem

I have a mono git repo with multiple submodules. When I want to update the template of a submodule, copier fails. Works fine when used directly with the git repository

Template

Not related to the template

To Reproduce

  1. Run copier in Git repository with submodules using copier update

Logs

No git tags found in template; using HEAD as ref
Updating to template version 0.0.0.post125.dev0+e257c8b
Traceback (most recent call last):
  File "/usr/local/bin/copier", line 8, in <module>
    sys.exit(copier_app_run())
             ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/plumbum/cli/application.py", line 638, in run
    inst, retcode = subapp.run(argv, exit=False)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/plumbum/cli/application.py", line 633, in run
    retcode = inst.main(*tailargs)
              ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/copier/cli.py", line 425, in main
    return _handle_exceptions(inner)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/copier/cli.py", line 70, in _handle_exceptions
    method()
  File "/usr/local/lib/python3.11/site-packages/copier/cli.py", line 415, in inner
    with self._worker(
  File "/usr/local/lib/python3.11/site-packages/copier/main.py", line 228, in __exit__
    raise value
  File "/usr/local/lib/python3.11/site-packages/copier/cli.py", line 423, in inner
    worker.run_update()
  File "/usr/local/lib/python3.11/site-packages/copier/main.py", line 899, in run_update
    self._apply_update()
  File "/usr/local/lib/python3.11/site-packages/copier/main.py", line 948, in _apply_update
    self._git_initialize_repo()
  File "/usr/local/lib/python3.11/site-packages/copier/main.py", line 1102, in _git_initialize_repo
    git("add", ".")
  File "/usr/local/lib/python3.11/site-packages/plumbum/commands/base.py", line 113, in __call__
    return self.run(args, **kwargs)[1]
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/plumbum/commands/base.py", line 252, in run
    return p.run()
           ^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/plumbum/commands/base.py", line 215, in runner
    return run_proc(p, retcode, timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/plumbum/commands/processes.py", line 328, in run_proc
    return _check_process(proc, retcode, timeout, stdout, stderr)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/plumbum/commands/processes.py", line 17, in _check_process
    proc.verify(retcode, timeout, stdout, stderr)
  File "/usr/local/lib/python3.11/site-packages/plumbum/machines/base.py", line 27, in verify
    raise ProcessExecutionError(
plumbum.commands.processes.ProcessExecutionError: Unexpected exit code: 128
Command line: | /usr/local/bin/git add .
Stderr:       | fatal: not a git repository: /tmp/copier.main.dst_copy.j3cp07a8/../.git/modules/<REDACTED>

Expected behavior

Simply update the template

Screenshots/screencasts/logs

No response

Operating system

Linux

Operating system distribution and version

Linux 11125168f804 5.15.153.1-microsoft-standard-WSL2 #1 SMP Fri Mar 29 23:14:13 UTC 2024 x86_64 GNU/Linux

Copier version

9.3.1

Python version

3.11.8

Installation method

pip+git

Additional context

No response

twsl avatar Oct 09 '24 11:10 twsl

Thanks for reporting this problem, @twsl! :pray:

Two requests please:

  1. Could you try the latest Copier version from the master branch? In #1711, we've made some changes to the affected section of the update algorithm, so the problem might have been fixed already.
  2. Could you provide a reproducible example?

sisp avatar Oct 11 '24 14:10 sisp

Seems like that seems to have already fixed the issue.

twsl avatar Oct 14 '24 06:10 twsl

If you provide a reproducible example, I can add a test case to make sure we don't break this scenario in the future.

sisp avatar Oct 14 '24 07:10 sisp

A reproducible example is just a git repo with a submodule and the submodule contains a copier template, that im trying to update. Not to sure, how and where you'd like me to create such an example. As a seperate repository?

twsl avatar Oct 15 '24 12:10 twsl