Skip to content

clone via branch does not create a project dir #380

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

Closed
ericpaulsen opened this issue Oct 2, 2024 · 4 comments · Fixed by #381
Closed

clone via branch does not create a project dir #380

ericpaulsen opened this issue Oct 2, 2024 · 4 comments · Fixed by #381
Assignees

Comments

@ericpaulsen
Copy link
Member

from a prospective customer:

when creating a devcontainer workspace via a direct repo link (e.g. https://github.com/org/repo-name), the envbuilder clones the repo into the repo-name directory, so you get /workspaces/repo-name/… , but when creating via a branch link (e.g. https://github.com/org/repo-name/#refs/heads/jon-coder), the envbuilder seems to clone the repo contents directly into workspaces, so you get /workspaces/

this is blocking their devcontainer use-case with Coder, because their build/service scripts rely on the source path in order to work, so the project not being in /workspaces/repo-name/ is breaking the services.

@ericpaulsen ericpaulsen added the bug label Oct 2, 2024
@mafredri mafredri self-assigned this Oct 3, 2024
@mafredri
Copy link
Member

mafredri commented Oct 3, 2024

@ericpaulsen I'm trying to reproduce this with envbuilder 1.0 but it seems to work as expected. Could you provide the following additional information:

  • Envbuilder version
  • Exact Git URL format (e.g. https://[redacted].git#refs/heads/...)
  • Whether or not ENVBUILDER_WORKSPACE_FOLDER is set and to which value
  • Are any other GIT_ options being used, like GIT_CLONE_SINGLE_BRANCH?

Edit: This was possibly fixed in #188.

@JonathanSun
Copy link

I believe it’s a bug in this code:

func DefaultWorkspaceFolder(repoURL string) string {

I’m able to reproduce by testing the code locally on an input like https://github.com/[org]/[repo]/#refs/heads/[branch]

Specifically this line:

name := strings.Split(parsed.Path, "/")

For the URL https://github.com/[org]/[repo]/#refs/heads/[branch], this results in name:
["", "[org]", "[repo]", ""]
and the last argument ("") is chosen as the repo name instead of the proper name.

The same issue can be noticed by adding an extra / to any non-branch URL, i.e. https://github.com/[org]/[repo]/. Also note that it doesn't matter whether .git is added to the repo identifier or not.

@ericpaulsen
Copy link
Member Author

@JonathanSun @mafredri i am also able to reproduce:

i just reproduced this on dev.coder.com using the Devcontainers template and the following URL:

https://github.com/coder/coder/#refs/heads/cred-helper

no ENVBUILDER_* environment variables are set in the template. here's my GIT_* vars:

$ env | grep GIT
GIT_SSH_COMMAND=/tmp/coder.vPtbyP/coder gitssh --
GIT_COMMITTER_NAME=eric
GIT_ASKPASS=/tmp/coder.vPtbyP/coder
[email protected]
[email protected]
GIT_AUTHOR_NAME=eric

@mafredri
Copy link
Member

mafredri commented Oct 4, 2024

Thanks @JonathanSun for your investigation and @ericpaulsen for verification, I can also reproduce this by adding the trailing slash 👍🏻

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 a pull request may close this issue.

4 participants