goldstar611 / gitless

A maintained fork of the simple git interface
https://goldstar611.github.io/gitless/
MIT License
26 stars 2 forks source link

[future request] Adding the equivalent of git clone #25

Closed sirlucjan closed 2 years ago

sirlucjan commented 2 years ago

Would it be possible to add a git clone equivalent? A very cool option would be to simplify downloading a single branch or downloading only the tagged version. Something like

gl download --branch=master https://github.com/goldstar611/gitless

or

gl download --tag=0.9.14 https://github.com/goldstar611/gitless

or

gl download --commit=90e197 https://github.com/goldstar611/gitless

goldstar611 commented 2 years ago

A very similar feature exists in gl init already but it didnt work for me when I tried.

usage: gl init [-h] [-o ONLY [ONLY ...]] [-e EXCLUDE [EXCLUDE ...]] [repo]
...
  -o ONLY [ONLY ...], --only ONLY [ONLY ...]
                        use only branches given from remote repo
  -e EXCLUDE [EXCLUDE ...], --exclude EXCLUDE [EXCLUDE ...]
                        use everything but these branches from remote repo

Todo (for me)

sirlucjan commented 2 years ago

I think commits can be let go, probably not worth it. I am very happy that gitless will get a download feature.

goldstar611 commented 2 years ago

I'm looking at this issue again and seeing how it maps to the official git client. It looks like the related git clone options would be

       --depth <depth>
           Create a shallow clone with a history truncated to the specified number of commits. Implies --single-branch unless --no-single-branch is given to fetch the histories near the tips of all branches. If you want to clone
           submodules shallowly, also pass --shallow-submodules.

       --shallow-since=<date>
           Create a shallow clone with a history after the specified time.

       --shallow-exclude=<revision>
           Create a shallow clone with a history, excluding commits reachable from a specified remote branch or tag. This option can be specified multiple times.

I think gitless can't support these git clone options because of pygit2/libgit2. See https://github.com/goldstar611/gitless/issues/20 All of the history must be in the repo unfortunately so I think the current options (-e, -o) are the best we can do currently to keep gl branch looking clean.

Let me know if you can think of a different way we could approach this, I'll look into it.

sirlucjan commented 2 years ago

In that case, no problem, it is always possible to use git clone for this. Alternatively we can make a wrapper similar to pull and fetch but I don't think it is necessary, git clone is used rather less often than fetch and pull.

sirlucjan commented 2 years ago

@goldstar611 I tried making a wrapper similar to gl pull and gl fetch but without success. I think it is not worth to pursue the topic further and close the topic.