seeraven / gitcache

Local cache for git repositories to speed up working with large repositories and multiple clones.
BSD 3-Clause "New" or "Revised" License
40 stars 8 forks source link

Unable to clone using git submodule #24

Closed Destrocamil closed 7 months ago

Destrocamil commented 8 months ago

Hello, I am trying to use gitcache but it throws me an error.

PS B:\gitlab\0\-software> gitcache git submodule update --init --recursive --depth 1 --recursive
2024-03-14 18:31:37 Save configuration file /.gitcache\config.
2024-03-14 18:31:38 Starting Fetch.
2024-03-14 18:31:40 Fetch was successfully completed within 1.5 seconds.
2024-03-14 18:31:40 Starting Fetch.
2024-03-14 18:31:42 Fetch was successfully completed within 1.5 seconds.
2024-03-14 18:31:43 Starting Fetch.
2024-03-14 18:31:44 Fetch was successfully completed within 1.3 seconds.
2024-03-14 18:31:44 Starting Fetch.
2024-03-14 18:31:46 Fetch was successfully completed within 1.5 seconds.
2024-03-14 18:31:46 Starting Fetch.
2024-03-14 18:31:48 Fetch was successfully completed within 1.3 seconds.
Traceback (most recent call last):
  File "\\vboxsvr\vagrant\gitcache", line 47, in <module>
  File "git_cache\git_command.py", line 113, in handle_git_command
  File "git_cache\commands\submodule_update.py", line 115, in git_submodule_update
IndexError: list index out of range
[2464] Failed to execute script 'gitcache' due to unhandled exception!
PS B:\gitlab\0\-software> gitcache git submodule update
2024-03-14 18:31:58 Starting Fetch.
2024-03-14 18:32:00 Fetch was successfully completed within 1.3 seconds.
2024-03-14 18:32:00 Starting Fetch.
2024-03-14 18:32:02 Fetch was successfully completed within 2.0 seconds.
2024-03-14 18:32:03 Starting Fetch.
2024-03-14 18:32:05 Fetch was successfully completed within 1.8 seconds.
2024-03-14 18:32:05 Starting Fetch.
2024-03-14 18:32:07 Fetch was successfully completed within 1.5 seconds.
2024-03-14 18:32:07 Starting Fetch.
2024-03-14 18:32:08 Fetch was successfully completed within 1.3 seconds.
Traceback (most recent call last):
  File "\\vboxsvr\vagrant\gitcache", line 47, in <module>
  File "git_cache\git_command.py", line 113, in handle_git_command
  File "git_cache\commands\submodule_update.py", line 115, in git_submodule_update
IndexError: list index out of range
[6956] Failed to execute script 'gitcache' due to unhandled exception!
PS B:\gitlab\0\-software> gitcache git submodule update --init
2024-03-14 18:34:30 Starting Fetch.
2024-03-14 18:34:31 Fetch was successfully completed within 1.5 seconds.
2024-03-14 18:34:32 Starting Fetch.
2024-03-14 18:34:33 Fetch was successfully completed within 1.5 seconds.
2024-03-14 18:34:34 Starting Fetch.
2024-03-14 18:34:35 Fetch was successfully completed within 1.5 seconds.
2024-03-14 18:34:36 Starting Fetch.
2024-03-14 18:34:37 Fetch was successfully completed within 1.5 seconds.
2024-03-14 18:34:38 Starting Fetch.
2024-03-14 18:34:39 Fetch was successfully completed within 1.3 seconds.
Traceback (most recent call last):
  File "\\vboxsvr\vagrant\gitcache", line 47, in <module>
  File "git_cache\git_command.py", line 113, in handle_git_command
  File "git_cache\commands\submodule_update.py", line 115, in git_submodule_update
IndexError: list index out of range
[1808] Failed to execute script 'gitcache' due to unhandled exception!

If I run simply git submodule update (...) it works, but gitcache shows 0 stats. I created the symlink and gitcache is before git in the PATH.

Any help is appreciated! Thanks a lot

seeraven commented 8 months ago

According to the exception it seems like a problem when analyzing the .gitmodules file of the parent or any child repository. The part that raises the exception tries to split the URL of a repository by the // string, so somehow a repository without a URL containing // is pulled in (perhaps some local repository?).

Since it is a recursive call, it is not so obvious weather the parent .gitmodules or any of the child .gitmodules is triggering the error. Can you run the command with debugging output by setting the environment variable GITCACHE_LOGLEVEL to Debug? I guess that will allow us to identify the module or at least give a better overview. The .gitmodules of the parent and recursively all children would also very helpful. Can you post those outputs/files here?

Youw commented 7 months ago

I just tried that:

2024-04-25 12:01:08 Python executable: /home/jenkins/bin/gitcache_v1.0.13_Ubuntu20.04_x86_64
2024-04-25 12:01:08 Called as ['git', 'submodule', 'update', '--init', '--recursive']
2024-04-25 12:01:08 handle_git_command(['git'], ['submodule', 'update', '--init', '--recursive']) started
2024-04-25 12:01:08 Found global options [], command 'submodule_update', command options '['--init', '--recursive']' and arguments [].
2024-04-25 12:01:08 Python executable: /home/jenkins/bin/gitcache_v1.0.13_Ubuntu20.04_x86_64
2024-04-25 12:01:08 Called as ['git', 'submodule', 'init']
2024-04-25 12:01:08 handle_git_command(['git'], ['submodule', 'init']) started
2024-04-25 12:01:08 Found global options [], command 'submodule_init', command options '[]' and arguments [].
2024-04-25 12:01:08 Loading configuration file /home/jenkins/.gitcache/config.
2024-04-25 12:01:08 Loading configuration file /home/jenkins/.gitcache/config.
2024-04-25 12:01:08 Loading configuration file /home/jenkins/.gitcache/config.
2024-04-25 12:01:08 Loading configuration file /home/jenkins/.gitcache/config.
2024-04-25 12:01:08 Loading configuration file /home/jenkins/.gitcache/config.
2024-04-25 12:01:08 Loading configuration file /home/jenkins/.gitcache/config.
2024-04-25 12:01:08 Loading configuration file /home/jenkins/.gitcache/config.
2024-04-25 12:01:08 Loading configuration file /home/jenkins/.gitcache/config.
2024-04-25 12:01:08 Loading configuration file /home/jenkins/.gitcache/config.
2024-04-25 12:01:08 Loading configuration file /home/jenkins/.gitcache/config.
2024-04-25 12:01:08 Loading configuration file /home/jenkins/.gitcache/config.
2024-04-25 12:01:08 Loading configuration file /home/jenkins/.gitcache/config.
Traceback (most recent call last):
  File "gitcache.py", line 51, in <module>
  File "git_cache/git_command.py", line 117, in handle_git_command
  File "git_cache/commands/submodule_update.py", line 114, in git_submodule_update
IndexError: list index out of range
[1347714] Failed to execute script 'gitcache' due to unhandled exception!
Youw commented 7 months ago

I just figured the simplest configuration to reproduce this: have a submodule in a relative path form, e.g: ../<submodule repo>.git and clone the main repo as git@github.com:<repo>.