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

Cannot use template hosted in Azure Devops Git #1956

Closed
cakriwut opened this issue Feb 1, 2025 · 2 comments
Closed

Cannot use template hosted in Azure Devops Git #1956

cakriwut opened this issue Feb 1, 2025 · 2 comments
Labels
bug triage Trying to make sure if this is valid or not

Comments

@cakriwut
Copy link

cakriwut commented Feb 1, 2025

Describe the problem

Azure Devops git repository is published in following url https://{organization}@dev.azure.com/{organization}/{project-name}/_git/{repo-name} . Unlike other git repo that ends with .git , the Azure Devops git repository doesnt end with .git.

When I run following command
copier copy https://{organization}@dev.azure.com/{organization}/{project-name}/_git/{repo-name} sample

it always throws following exception ValueError: Local template must be a directory.

Template

# Project options
team_project:
  type: str
  help: |
    The name of the Azure DevOps project where the pipelines will be created.
    This is the name of the project, not the organization , not the name of the repository.

project_name:
  type: str
  help: "What is your project name"

_message_after_copy: |
  Your project "{{ project_name }}" has been created successfully!

  Next steps:
  1. cd {{ project_name }}
  2. Read the README.md file and update it with your project information
  3. Run 'python -m venv venv' to create a virtual environment and activate it
  4. Run 'pip install -r requirements.txt' to install the project dependencies
  5. Start coding!

_message_after_update: |
    Your project "{{ project_name }}" has been updated successfully!
    In case there are any conflicts, please resolve them. Then,
    you're done.

_tasks:
  # OS-specific task (supported values are "linux", "macos", "windows" and `None`)
  - command: find docs -type f -name "*.md" ! -name "Readme.md" -exec rm {} +
    when: "{{ _copier_conf.os in  ['linux', 'macos'] }}"
  - command: for %i in (docs\*.md) do @if /i not "%~nxi"=="Readme.md" del "%i"
    when: "{{ _copier_conf.os == 'windows' }}"

To Reproduce

copier copy https://{organization}@dev.azure.com/{organization}/{project-name}/_git/{repo-name} sample

Logs

Traceback (most recent call last):
  File "...\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "...\Python\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "....local\bin\copier.exe\__main__.py", line 7, in <module>
  File "...pipx\venvs\copier\lib\site-packages\plumbum\cli\application.py", line 640, in run
    inst, retcode = subapp.run(argv, exit=False)
  File "...pipx\venvs\copier\lib\site-packages\plumbum\cli\application.py", line 635, in run
    retcode = inst.main(*tailargs)
  File "...pipx\venvs\copier\lib\site-packages\copier\cli.py", line 281, in main
    return _handle_exceptions(inner)
  File "...pipx\venvs\copier\lib\site-packages\copier\cli.py", line 70, in _handle_exceptions
    method()
  File "...pipx\venvs\copier\lib\site-packages\copier\cli.py", line 279, in inner
    worker.run_copy()
  File "...pipx\venvs\copier\lib\site-packages\copier\main.py", line 237, in __exit__
    raise value
  File "...pipx\venvs\copier\lib\site-packages\copier\cli.py", line 279, in inner
    worker.run_copy()
  File "...pipx\venvs\copier\lib\site-packages\copier\main.py", line 832, in run_copy
    self._print_message(self.template.message_before_copy)
  File "...\Python\Python39\lib\functools.py", line 993, in __get__
    val = self.func(instance)
  File "...pipx\venvs\copier\lib\site-packages\copier\template.py", line 352, in message_before_copy
    return self.config_data.get("message_before_copy", "")
  File "...\Python\Python39\lib\functools.py", line 993, in __get__
    val = self.func(instance)
  File "...pipx\venvs\copier\lib\site-packages\copier\template.py", line 300, in config_data
    result = filter_config(self._raw_config)[0]
  File "...\Python\Python39\lib\functools.py", line 993, in __get__
    val = self.func(instance)
  File "...pipx\venvs\copier\lib\site-packages\copier\template.py", line 257, in _raw_config
    for p in self.local_abspath.glob("copier.*")
  File "...\Python\Python39\lib\functools.py", line 993, in __get__
    val = self.func(instance)
  File "...pipx\venvs\copier\lib\site-packages\copier\template.py", line 559, in local_abspath
    raise ValueError("Local template must be a directory.")
ValueError: Local template must be a directory.

Expected behavior

Should works.
I can clone the repo and do copier cloned_path target_path

Screenshots/screencasts/logs

No response

Operating system

Windows

Operating system distribution and version

Windows 11

Copier version

copier 9.4.1

Python version

Python 3.9.13

Installation method

pipx+pypi

Additional context

pipx

@cakriwut cakriwut added bug triage Trying to make sure if this is valid or not labels Feb 1, 2025
@laenan8466
Copy link

laenan8466 commented Feb 7, 2025

I use this workaround:

copier copy git+https://{organization}@dev.azure.com/{organization}/{project-name}/_git/{repo-name} sample

or

copier copy git+ssh.dev.azure.com:v3/{organization}/{project-name}/{repo-name} sample

I would agree, that copier should detect the 'normal' url of Azure DevOps, without the git+ addition.

@yajo
Copy link
Member

yajo commented Feb 8, 2025

It's not a workaround. It's just the way to do it! Thanks ❤

@yajo yajo closed this as completed Feb 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug triage Trying to make sure if this is valid or not
Projects
None yet
Development

No branches or pull requests

3 participants