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

Recent repositories #3813

Open
tmarti2 opened this issue Aug 9, 2024 · 14 comments
Open

Recent repositories #3813

tmarti2 opened this issue Aug 9, 2024 · 14 comments

Comments

@tmarti2
Copy link

tmarti2 commented Aug 9, 2024

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
Copy link
Collaborator

mark2185 commented Aug 9, 2024

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
Copy link
Author

tmarti2 commented Aug 9, 2024

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
Copy link
Collaborator

mark2185 commented Aug 9, 2024

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
Copy link
Author

tmarti2 commented Aug 9, 2024

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

  • dir1
  • dir2
  • dir3

Open dir4 and dir5, recent repositories :

  • dir1
  • dir2
  • dir3
  • dir4
  • dir5

Today when I open my recent repositories, there are only

  • dir1
  • dir2
  • dir3

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
Copy link
Collaborator

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:

  • start with an empty list of repos
  • open lazygit in dir1 (state.yml now contains dir1)
  • open another lazygit instance in dir2 (state.yml now contains dir1 and dir2)
  • make some change to the app state in the first lazygit instance (for example, show or hide the command log)
  • this will remove dir2 again from state.yml

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
Copy link
Author

tmarti2 commented Aug 9, 2024

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
Copy link
Collaborator

mark2185 commented Aug 9, 2024

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
Copy link
Author

tmarti2 commented Aug 9, 2024

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
Copy link
Collaborator

mark2185 commented Aug 9, 2024

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

@tmarti2
Copy link
Author

tmarti2 commented Aug 9, 2024

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
Copy link
Collaborator

mark2185 commented Aug 9, 2024

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
Copy link
Author

tmarti2 commented Aug 9, 2024

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

@Ridermansb
Copy link

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

image

@mark2185
Copy link
Collaborator

mark2185 commented Oct 4, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants