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

remove all current groups/repos #213

Closed
bcdiaconu opened this issue Jan 28, 2022 · 8 comments
Closed

remove all current groups/repos #213

bcdiaconu opened this issue Jan 28, 2022 · 8 comments

Comments

@bcdiaconu
Copy link
Contributor

bcdiaconu commented Jan 28, 2022

when changing context would be great to be able to get rid of previously created gita repos/groups. one approach could be gita rm *. another one could be gita clear.

in the new context, one could simply run gita add -a . to automatically create groups and add repos. this will keep context small and easy to manage

@bcdiaconu bcdiaconu changed the title clean current groups/repos remove all current groups/repos Jan 28, 2022
@nosarthur
Copy link
Owner

By 'context', do you mean the one in gita context, which can be set to a group name or 'auto' or 'none'? When set, only repos in the context will be shown or act on.

Or maybe you just want to start brand new?

In the latter case, you can delete two files in ~/.config/gita/: groups.csv and repos.csv

@bcdiaconu
Copy link
Contributor Author

bcdiaconu commented Jan 29, 2022

By context I mean working workspace rather than gita's context. I will use workspace instead of context to avoid terminology overlapping.

I could have several tens or hundred of workspaces with a few potential groups and repos. In this scenarios, always having them all in gita, would be a hard thing to manage. Think of only running an gita groupcommand. One could search through a full screen of groups for the desired one.

The proposed conceptual workflow is that when moving to a new workspace directory, that contains several groups and projects it is desirable to start with a clean gita by running a gita rm * or gita clear and than simply run a gita add -a . to populate Gita with only desirable ones. That way all becomes simplified and focused on the current workspace, no matter what gita command.

To achieve this, always removing the files manually when changing workspace would be tedious.

@nosarthur
Copy link
Owner

gita clear is surely a possibility.

From your description, gita add -a <workspace folder1> <workspace folder2> ... seems to be the way to go. Then you can set gita context auto, which will automatically change context for you, based on your current working directory

@nosarthur
Copy link
Owner

The inner working of auto context:

When you run gita add -a ., the automatically-created groups also contain 'group path' (see ~/.config/gita/groups.csv for examples). When auto context is on, cwd is compared to group paths to figure out which group is the current context.

For groups not added from gita add -a, you can manually assign group path using gita group add -p <some path>. A typical usage case:

/enclosing-folder
  /repo1
  /repo2
  /some-other-folder
      /repo3

Say you manually added those 3 repos into a group, then you can also assign the enclosing folder as the group path.

@bcdiaconu
Copy link
Contributor Author

bcdiaconu commented Jan 29, 2022

gita clear is surely a possibility.

From your description, gita add -a <workspace folder1> <workspace folder2> ... seems to be the way to go. Then you can set gita context auto, which will automatically change context for you, based on your current working directory

i was thinking more in the line of gita add -a <workspace> and all projects belonging to that workspace are populated automatically with groups created also automatically based on dir structure

@bcdiaconu
Copy link
Contributor Author

bcdiaconu commented Jan 29, 2022

The inner working of auto context:

When you run gita add -a ., the automatically-created groups also contain 'group path' (see ~/.config/gita/groups.csv for examples). When auto context is on, cwd is compared to group paths to figure out which group is the current context.

For groups not added from gita add -a, you can manually assign group path using gita group add -p <some path>. A typical usage case:

/enclosing-folder
  /repo1
  /repo2
  /some-other-folder
      /repo3

Say you manually added those 3 repos into a group, then you can also assign the enclosing folder as the group path.

I know about auto context. however when later one would want to do a push on all repos of the workspace with gita, without changing directory to root workspace, it cannot run gita context none followed by gita push. He still has to either change dir to root workspace or either to know or to find the group for the whole workspace.

Later edit:
I have just tried and it seems gita push without a group or repo does not work actually. But gita pull does work. I think it would make sense to make it a consistent optional parameter [repo | group, ...] and also add gita clear or gita reset. what do you think?

@bcdiaconu
Copy link
Contributor Author

bcdiaconu commented Jan 29, 2022

I started working on it here: #214

Later edit:
Marked PR ready for review

@nosarthur
Copy link
Owner

nosarthur commented Jan 29, 2022

i was thinking more in the line of gita add -a and all projects belonging to that workspace are populated automatically with groups created also automatically based on dir structure

This is the same as what I suggest. If you run gita add -a /, then all repos will be added. I was assuming there are several very far-apart folders, each containing some repos with some hierarchy, then one can add -a on them.

I know about auto context. however when later one would want to do a push on all repos of the workspace with gita, without changing directory to root workspace, it cannot run gita context none followed by gita push. He still has to either change dir to root workspace or either to know or to find the group for the whole workspace

It sounds like a bug. Can you give more details? What is the procedure to trigger the problem?

Suppose you are done working on one workspace (from your description, it seems to be the same as 'context' in gita, i.e., a group). I guess at the point you want to push the changes for that group, then there are two options

  1. if you know the name of the group, then gita push <group-name>
  2. if you have auto context on, and you are in the right group path, then gita push (this requires your PR). The scope of the git operation is the same as gita ll scope, so you can check with that

In this workflow, it seems gita clear is not really needed (it's redundant to clear and add -a again and again). But it doesn't hurt to have it.

I have just tried and it seems gita push without a group or repo does not work actually. But gita pull does work. I think it would make sense to make it a consistent optional parameter [repo | group, ...] and also add gita clear or gita reset. what do you think?

I deliberately disallowed that for push, but it makes sense to let user do whatever they want.

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

No branches or pull requests

2 participants