gita icon indicating copy to clipboard operation
gita copied to clipboard

Feature Request: gita ll --work

Open Blackstareye opened this issue 3 years ago • 8 comments

Hi :)

while using your awesome tool, I came to the issue that I have a LOT of repos (211+). And it would be nice if it were possible to only list the "todo" repos.

I thought a flag on the gita ll command could trigger the filter, to show only the repos which are marked (+,*,_).

What do you think ?

Blackstareye avatar Jun 29 '21 23:06 Blackstareye

There are two mechanisms to organize repos in gita

  1. make groups using gita group command. Then you can set context to show only one group or do gita ll some-group to show only one group
  2. use the workspace mechanism by defining 'main' repos via gita add -m <main repo>. This main repo contains other repos. And when you enter the main repo or any of its subdirectories, only the related repos will be shown in gita ll

Would it make sense to use these two mechanisms in your case?

I find it strange to show only marked repos. Maybe I don't understand your workflow ...

nosarthur avatar Jun 30 '21 02:06 nosarthur

Gita group has the flaw that I have to tag every repo on my own, cause -r does not have an auto group tagging :/

My usecase is the following:

I have a lot of repos on my computer, cause I handle nearly everything with repos. Ideas, Projects, Assets etc. Also my knowledgebase is based on that.

Cause I am on Windows its nearly impossible to have a place for all repos, cause they have different backup strategies and other usecases. I don't want all in one place. I would love to have sym links for that, but in Windows we only have shortcuts and hardlinks that are a mess...

So yeah I am using your tool with wsl, and it works pretty well. All my repos are registered with "-r" flag.

BUT because I have many repos (200+), it's a bit slow to run a gita ll. And I don't want to maintain groups to be honest.

So a flat -r based repo index is awesome for my use case.

====

But here comes the flaw:

If I run gita ll, it is really slow, and the output is crowded with repos, that don't have anything todo.

So I came to the idea, that it would be nice to have a kind of a grep filter for displaying only repos that needs work .

Your program is my hero and manager for all my repos so that I don't forget to push anything to my servers. So thank you for that ! :)

====

So I hope you may understand now my usecase and scenario better.

Let me know if something is still unclear.

Blackstareye avatar Jul 08 '21 13:07 Blackstareye

Thanks for the explanation. Since we need to run some git command to know which repos 'need work', I am not sure if that will solve the performance issue. It might be comparable to running gita ll then grepping the lines with edit status (the 3rd column contains *+_)

On the other hand, it's easy to auto-group when gita add -r. Say, group all repos in some-path when running gita add -r -mkgroup some-path. Would you be interested in that?

Another option is to add editing status to the groups, which comes from the component repos and only takes on 2 values: with edits and without. Here we can run on all component repos and return early as long as 1 of them is not clean, which helps the performance. Then one can display that group for details

The format is something like this: gita group ll -s (s for status), and the return is

group1*: [repo1, repo2, ...]
group2: [...]
group3*: [...]

and the asterisk indicates that some repo in the group has edits.

There is also another feature request #101 related to this. If I understand it correctly, the goal is to automatically generate hierarchical groups based on the folder structure.

Let me know what you think. Your original request is surely a possibility too. In that case, do you want to trigger it by any of *+_?

nosarthur avatar Jul 08 '21 13:07 nosarthur

I can also add a sync sub-command

nosarthur avatar Jul 08 '21 14:07 nosarthur

Those are great ideas.

I think the auto group tagging can be useful in many usecases. Combined with the status it can help a lot. So it would be also possible to have a list of groups and their status directly accessible which opens the gate for many other cool usecases for handling group activity.

I would be down for that :)

About the Sync Command, I don't really know what do you mean with that. Can you explain that ? :)

Many thanks for your quick answers! :)

Blackstareye avatar Jul 09 '21 13:07 Blackstareye

For the sync command, I was thinking of git ci -am 'add changes' and then push. Maybe it's too aggressive

nosarthur avatar Jul 10 '21 19:07 nosarthur

@Blackstareye the auto group feature is already in 0.15.1, let me know how that works for you

nosarthur avatar Jul 18 '21 02:07 nosarthur

I would also really like a way to only show/filter the repos which have for example non-trivial edit status or which are not up to date with remote. It's nice to quickly see which repos might need attention.

AckslD avatar Feb 16 '22 07:02 AckslD

a minor update: someone implemented threadpool for gita ll #238 . It is much faster now

nosarthur avatar Jul 19 '23 02:07 nosarthur

@AckslD Apart from the speed issue, you can make an alias for gita ll |rg -v '\[\]' (rg is a faster version of grep)

image

nosarthur avatar Jul 19 '23 02:07 nosarthur

maybe we can close this case already?

nosarthur avatar Jul 19 '23 02:07 nosarthur

I have a workflow very similar to what is specified in #237 . The bash aliases mentioned help manage the workflow. I'm not sure if we need something within gita

Aliases defined:

alias staged="gita ll -C |rg '[\+]'| cut -d ' ' -f1"
alias dirty="gita ll -C |rg '[\*]'| cut -d ' ' -f1"
alias untracked="gita ll -C |rg '[\?]'| cut -d ' ' -f1"
alias local_ahead="gita ll -C |rg '[↑]'| cut -d ' ' -f1"
alias remote_ahead="gita ll -C |rg '[↓]'| cut -d ' ' -f1"
alias diverged="gita ll -C |rg '[⇕]'| cut -d ' ' -f1"
alias no_remote="gita ll -C |rg '[∅]'| cut -d ' ' -f1"

My workflow with only aliases:

  1. Modify repositories under a single folder based on changes required e.g. Bumping up a library dependency across build.gradle files in each repository
  2. gita super (staged) git commit -m "Bump library dependency" .
  3. gita super (local_ahead) checkout -b bump-dependency
  4. gita shell (no_remote) glab mr create --fill --remove-source-branch

The challenge with the above approach is that the 'workspace' shifts with every action. I guess an alternative is to define a temporary active workspace ?

Modified workflow with temporary active group:

  1. Modify repositories under a single folder based on changes required e.g. Bumping up a library dependency across build.gradle files in each repository
  2. gita group add -n active (staged)
  3. gita super active git commit -m "Bump library dependency" .
  4. gita super active checkout -b bump-dependency
  5. gita shell active glab mr create --fill --remove-source-branch

Thanks for building gita. I find it super useful!

anaynayak avatar Jul 27 '23 13:07 anaynayak