The tool scans the .git folders in the provided path and creates a slice of repository paths. It then saves these paths to a file called .gogitlocalstats in the user's home directory.
However, there is a bug in the current implementation. When saving the paths to the file, the tool retrieves the existing paths from the file and adds them to the slice. It checks each path to ensure it is not already present in the slice. If a path is not found in the slice, it is added. Finally, the tool overwrites the contents of the file with the updated slice of paths.
The issue arises when a user removes a repository and then runs the tool again. Since the previous paths from the .gogitlocalstats file are added to the slice without checking their existence, the removed repository's path is still included. This leads to errors when the tool tries to access a non-existent repository, resulting in unexpected panics.
Error Message:
panic: repository does not exist
goroutine 1 [running]:
main.fillCommits(path, otherParams)
stats.go:38
main.processRepositories(params)
stats.go:135
main.stats(params)
stats.go:20
main.main()
main.go:18
Expected Behavior:
The tool should handle repository removals gracefully, without causing a panic. It should ignore non-existent paths in the .gogitlocalstats file and continue processing the remaining repositories.
Steps to Reproduce:
Add repositories to the .gogitlocalstats file. (By running the tool)
Remove one of the repositories from the file system.
Description:
The tool scans the
.git
folders in the provided path and creates a slice of repository paths. It then saves these paths to a file called.gogitlocalstats
in the user's home directory.However, there is a bug in the current implementation. When saving the paths to the file, the tool retrieves the existing paths from the file and adds them to the slice. It checks each path to ensure it is not already present in the slice. If a path is not found in the slice, it is added. Finally, the tool overwrites the contents of the file with the updated slice of paths.
The issue arises when a user removes a repository and then runs the tool again. Since the previous paths from the
.gogitlocalstats
file are added to the slice without checking their existence, the removed repository's path is still included. This leads to errors when the tool tries to access a non-existent repository, resulting in unexpected panics.Error Message:
Expected Behavior: The tool should handle repository removals gracefully, without causing a panic. It should ignore non-existent paths in the
.gogitlocalstats
file and continue processing the remaining repositories.Steps to Reproduce:
.gogitlocalstats
file. (By running the tool)Thank you!