gita icon indicating copy to clipboard operation
gita copied to clipboard

Command for cloning a git repo and adding it to a group

Open GordianDziwis opened this issue 2 years ago • 5 comments

I would like to do something like this:

gita clone -g Foo [email protected]:nosarthur/gita.git

The result would be the same as:

git clone [email protected]:nosarthur/gita.git
gita add -g Foo ./gita

GordianDziwis avatar Nov 22 '21 14:11 GordianDziwis

I think it's a good idea

nosarthur avatar Nov 22 '21 19:11 nosarthur

If i understand this correctly,

  1. 'gita clone' pulls from a config file rather than a single repo path
  2. 'gita add' adds an already cloned repo to the tracking but does not clone

the requested feature is a mix of both - clone a single repo, then add it.

So, change the 'clone' command to work with a single repo? Or change the 'add' command to allow cloning? Or, something else?

perhaps:

gita add -g Foo -u [email protected]:nosarthur/gita.git

-u meaning clone from url This would equivalent to:

git clone [email protected]:nosarthur/gita.git
gita add -g Foo ./gita

and

gita clone -g Foo config_file

clone all items from config_file and add to group Foo. (not what the poster asked, but along a similar idea) This would equilavent as something like

for url, name, path in config_file:
	git clone url name
	gita add -g Foo name

ackermanaviation avatar Jan 25 '22 16:01 ackermanaviation

Alternatively, maybe a more radical change?

merge clone and add:

'gita add -c config_file' same as 'gita clone config_file' 'gita add -c config_file -p' same as 'gita clone config_file -p' 'gita add -c config_file -g group' add all items from config_file and track in group [new] 'gita add -u url' clone repo from url, add to tracking without group [new] 'gita add -u url -g group' clone repo from url, add to group [new[ <=== requested item

all other 'gita add' remain as they currently are. 'gita clone' could be aliased and deprecated.

ackermanaviation avatar Jan 25 '22 16:01 ackermanaviation

Thanks @ackermanaviation for putting the thought. The gita clone command is indeed not well planned.

I prefer to leave gita add as it is since it already has too many options. And clean up gita clone instead. We should make it more like git clone, just like all the other gita commands, i.e.,

gita clone <url>

becomes

git clone <url>

at the current working directory.

Then we can add some options, say -C for where to clone to, -a for adding it to gita (gita add <cloned-repo-path>), -g for adding it to gita and also to a group, -f for using a config file (the current usage case), etc.

nosarthur avatar Jan 25 '22 17:01 nosarthur

gita clone refactoring is partially done in v0.16.2, -a and -g are still not implemented

https://github.com/nosarthur/gita/releases/tag/v0.16.2

nosarthur avatar Jan 30 '22 04:01 nosarthur

implemented in v0.16.6.1

nosarthur avatar Jul 18 '23 02:07 nosarthur