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

pdm init git@github.com:<USER>/<REPO>.git@<BRANCH_NAME> fails with <USER>/<REPO>.git@<BRANCH_NAME> is not a valid repository name #2597

Closed
1 task done
logan-hcg opened this issue Jan 30, 2024 · 2 comments · Fixed by j178/pdm#1
Labels
🐛 bug Something isn't working

Comments

@logan-hcg
Copy link

  • I have searched the issue tracker and believe that this is not a duplicate.

Make sure you run commands with -v flag before pasting the output.

Steps to reproduce

Run pdm init using a private repo and trying to check out a branch from Github.

pdm init git@github.com:<USER>/<REPO>.git@<BRANCH_NAME>

Actual behavior

Cloning into '<REPO>.git@<BRANCH_NAME>'...
fatal: remote error: 
 <USER>/<REPO>.git@<BRANCH_NAME>'is not a valid repository name
Visit https://support.github.com/ for help

Expected behavior

Should clone and checkout the template branch.

Environment Information

# Paste the output of `pdm info && pdm info --env` below:
PDM version:
  2.11.2
Python Interpreter:
  ~REDACTED~
Project Root:
  ~REDACTED~
Local Packages:
  
{
  "implementation_name": "cpython",
  "implementation_version": "3.10.13",
  "os_name": "posix",
  "platform_machine": "x86_64",
  "platform_release": "6.6.13-200.fc39.x86_64",
  "platform_system": "Linux",
  "platform_version": "#1 SMP PREEMPT_DYNAMIC Sat Jan 20 18:03:28 UTC 2024",
  "python_full_version": "3.10.13",
  "platform_python_implementation": "CPython",
  "python_version": "3.10",
  "sys_platform": "linux"
}
@logan-hcg logan-hcg added the 🐛 bug Something isn't working label Jan 30, 2024
@logan-hcg
Copy link
Author

I believe the issue is with the following code:

left, amp, right = url.rpartition("@")
if left != "git" and amp:
extra_args = [f"--branch={right}"]
else:
extra_args = []
git_command = ["git", "clone", "--recursive", "--depth=1", *extra_args, url, self._path.as_posix()]

I believe it should be something like:

        left, amp, right = url.rpartition("@")
        if left != "git" and amp:
            extra_args = [f"--branch={right}"]
            # reset the clone URL to remove the branch reference that is being passed as the `--branch` argument
            url = left
        else:
            extra_args = []
        git_command = ["git", "clone", "--recursive", "--depth=1", *extra_args, url, self._path.as_posix()]

Thoughts?

@frostming
Copy link
Collaborator

I believe it should be something like:

Oh, right. Would you like to submit a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants