jesseduffield / lazygit

simple terminal UI for git commands
MIT License
51.74k stars 1.82k forks source link

Recent repositories #3813

Open tmarti2 opened 2 months ago

tmarti2 commented 2 months ago

Hello !

I'm using lazygit for few months now and I love it !

I have a question regarding recent repositories, how does it work ? At the moment the list contains my main repository and old ones that I have not used since few weeks, but repositories I used yersterday do not appear anymore, why is that ?

Is there a way to configure lazygit to always show a list of repositories ? To make sure they do not disappear ? I did not found anything like that in config file but I may have missed it.

Thanks !

mark2185 commented 2 months ago

The recent repositories list should contain the list of all repositories the user has opened lazygit in. If you don't open lazygit in a repo, it won't appear in that list.

The cache is just a text file you can find in the folder that lazygit --cd returns, there's a state.yml that holds the state.

tmarti2 commented 2 months ago

The folder returned by lazygit --cd only contains config.yaml for me. I found a file state.yaml in ~/.local/state/lazygit, but I guess it is not "good practice" to update it here ? I tried to move it in my .config but it does not seems to work.

Is there a documentation for this file ?

mark2185 commented 2 months ago

The folder returned by lazygit --cd only contains config.yaml for me.

Okay, I might have been mistaken about the --cd flag then, my bad.

but I guess it is not "good practice" to update it here

It's generally not something users should edit manually so I don't think it's documented anywhere.

So what you're saying is that you run lazygit in a new git folder and the recentrepos in that state.yml doesn't update?

tmarti2 commented 2 months ago

So what you're saying is that you run lazygit in a new git folder and the recentrepos in that state.yml doesn't update?

When I open a new repo, it is correctly added in state.yaml. But sometimes, for reasons I do not understand, the list of recent repositories is update so that some repositories are removed.

For example, from yersterday/today update of my recent repositores :

Recent repositories yersterday

Open dir4 and dir5, recent repositories :

Today when I open my recent repositories, there are only

dir4 and dir5, which are the most recent ones, were removed, but older repo are still present. And I don't understand why my most recent repositories where deleted.

Sorry if that's not clear

stefanhaller commented 2 months ago

One reason I can see that might explain this is when you have multiple instances of lazygit running at the same time: they will overwrite each other's state.

For example:

It seems that we should be able to fix this by reloading state.yml whenever its modification date changed, similar to how I'm reloading the config file in #3787.

tmarti2 commented 2 months ago

Mhmm, I'm not sure I had more than 1 instance of lazygit at the time, but I'll be careful from now on.

Another cause might be that if repositories do not exist anymore they are removed from recent repo ? If a repositories is moved somewhere else (path in state.yaml does not exist anymore) then moved back, depending on when lazygit checks if it exists, it might delete the path ?

mark2185 commented 2 months ago

If a repositories is moved somewhere else (path in state.yaml does not exist anymore)

lazygit will remove invalid paths from state.yml on launch, so that would explain why they're gone.

Adding them again requires lazygit to be launched from the directory again, same as it was required the first time around.

tmarti2 commented 2 months ago

Ok so that explains why they disappear then, it was obvious but I did not think about it enough I guess.

It would be nice if it could keep the paths but only display valid ones, so that adding the repositories back to the right path would also make it appear in recent repositories again.

Thanks for helping me to figure this out !

mark2185 commented 2 months ago

Is moving repos around something you do often? If so, why? 🤔

tmarti2 commented 2 months ago

I'm developing inside a software which has external plugins, which have their own repositories. When I update this software, it can break external plugins. in order to compile/test them, the easiest way is to move these plugins inside the main software, in src/plugins (which contains internal plugins as well). Once the plugins are fixed, I move them out, because I do not want to compile / test them every time that I build/test the main software.

mark2185 commented 2 months ago

Alrighty then, I'd definitely suggest to explore the possibility of symlinks, so that you don't have to move the plugins here and there but just link and unlink. I'm not sure if it's applicable, but might be worth a shot.

tmarti2 commented 2 months ago

I never thought about this... you're a genius ! It works perfectly fine ! Thanks

Ridermansb commented 5 days ago

Still not clear to me where state.yml are found.

image

mark2185 commented 5 days ago

@Ridermansb according to the docs, on MacOS it should be in ~/Library/Application\ Support/lazygit/?