Skip to content

devbox create command clones entire repo when it only needs one commit #2487

Open
@yemaney

Description

Explanation

Creating a project using one of the templates will clone the entire history of the repo.
Only one commit is really needed in order to access the template files used to initialize a project.
Creating a shallow clone reduce the amount of history that is fetched which should increase speed a little without sacrificing any functionality.

Basic Tests

Regular Clone

$ time devbox create --template go test1
/usr/local/bin/git clone https://github.com/jetify-com/devbox -b 0.13.7 /tmp/devbox-template2215688715
Cloning into '/tmp/devbox-template2215688715'...
remote: Enumerating objects: 22103, done.
remote: Counting objects: 100% (2421/2421), done.
remote: Compressing objects: 100% (562/562), done.
remote: Total 22103 (delta 2114), reused 1863 (delta 1859), pack-reused 19682 (from 2)
Receiving objects: 100% (22103/22103), 41.41 MiB | 3.67 MiB/s, done.
Resolving deltas: 100% (14359/14359), done.
Note: switching to '270f8b2a010f03386d4dcd192eb89535df7b674b'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

/usr/bin/sh -c cp -r /tmp/devbox-template2215688715/examples/development/go/hello-world/* /workspaces/devbox/test1
Success: Initialized devbox project using template go

real    0m5.544s
user    0m3.616s
sys     0m3.159s

Shallow Clone

$ time ./dist/devbox create --template go test2
/usr/local/bin/git clone https://github.com/jetify-com/devbox -b main --depth 1 /tmp/devbox-template3699782114
Cloning into '/tmp/devbox-template3699782114'...
remote: Enumerating objects: 1468, done.
remote: Counting objects: 100% (1468/1468), done.
remote: Compressing objects: 100% (1175/1175), done.
remote: Total 1468 (delta 170), reused 1013 (delta 118), pack-reused 0 (from 0)
Receiving objects: 100% (1468/1468), 19.18 MiB | 10.71 MiB/s, done.
Resolving deltas: 100% (170/170), done.
/usr/bin/sh -c cp -r /tmp/devbox-template3699782114/examples/development/go/hello-world/* /workspaces/devbox/test2
Success: Initialized devbox project using template go

real    0m3.183s
user    0m1.086s
sys     0m1.632s

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions