markfinal / cruiz

Conan recipe user interface
https://cruiz.readthedocs.io/
Apache License 2.0
11 stars 1 forks source link

Loading a recipe from newly cloned, empty, repository fails to open because of Git #129

Closed foundry-markf closed 3 months ago

foundry-markf commented 1 year ago

The recipe fails to load (silently), but you can see the error on the console

(library_env310) C:\dev\conan_source_patch>python -m cruiz
Traceback (most recent call last):
  File "C:\dev\cruiz\cruiz\mainwindow.py", line 430, in load_recipe
    recipe_widget = RecipeWidget(recipe_path, recipe_uuid, wizard.local_cache)
  File "C:\dev\cruiz\cruiz\recipe\recipewidget.py", line 358, in __init__
    self._create_statusbar()
  File "C:\dev\cruiz\cruiz\recipe\recipewidget.py", line 586, in _create_statusbar
    self._refresh_statusbar()
  File "C:\dev\cruiz\cruiz\recipe\recipewidget.py", line 590, in _refresh_statusbar
    head_sha = self._git_repository.head.object.hexsha
  File "c:\dev\library_env310\lib\site-packages\git\refs\symbolic.py", line 219, in _get_object
    return Object.new_from_sha(self.repo, hex_to_bin(self.dereference_recursive(self.repo, self.path)))
  File "c:\dev\library_env310\lib\site-packages\git\refs\symbolic.py", line 159, in dereference_recursive
    hexsha, ref_path = cls._get_ref_info(repo, ref_path)
  File "c:\dev\library_env310\lib\site-packages\git\refs\symbolic.py", line 210, in _get_ref_info
    return cls._get_ref_info_helper(repo, ref_path)
  File "c:\dev\library_env310\lib\site-packages\git\refs\symbolic.py", line 193, in _get_ref_info_helper
    raise ValueError("Reference at %r does not exist" % ref_path)
ValueError: Reference at 'refs/heads/master' does not exist

Tested in 1.4.0.a4.dev7

foundry-markf commented 1 year ago

Doing a commit and push to the upstream resolves this.

However, the initial impression is "What happaned?" when the recipe doesn't show at all.

foundry-markf commented 4 months ago

Similarly, if the Git server to query is not contactable, you get this error:

Traceback (most recent call last):
  File "F:\cruiz\src\cruiz\mainwindow.py", line 458, in _open_recipe
    self.load_recipe(pathlib.Path(conan_file_path))
  File "F:\cruiz\src\cruiz\mainwindow.py", line 432, in load_recipe
    recipe_widget = RecipeWidget(recipe_path, recipe_uuid, wizard.local_cache)
  File "F:\cruiz\src\cruiz\recipe\recipewidget.py", line 358, in __init__
    self._create_statusbar()
  File "F:\cruiz\src\cruiz\recipe\recipewidget.py", line 586, in _create_statusbar
    self._refresh_statusbar()
  File "F:\cruiz\src\cruiz\recipe\recipewidget.py", line 590, in _refresh_statusbar
    head_sha = self._git_repository.head.object.hexsha
  File "F:\conan\library_env310\lib\site-packages\git\refs\symbolic.py", line 219, in _get_object
    return Object.new_from_sha(self.repo, hex_to_bin(self.dereference_recursive(self.repo, self.path)))
  File "F:\conan\library_env310\lib\site-packages\git\objects\base.py", line 94, in new_from_sha
    oinfo = repo.odb.info(sha1)
  File "F:\conan\library_env310\lib\site-packages\git\db.py", line 40, in info
    hexsha, typename, size = self._git.get_object_header(bin_to_hex(binsha))
  File "F:\conan\library_env310\lib\site-packages\git\cmd.py", line 1383, in get_object_header
    return self.__get_object_header(cmd, ref)
  File "F:\conan\library_env310\lib\site-packages\git\cmd.py", line 1370, in __get_object_header
    return self._parse_object_header(cmd.stdout.readline())
  File "F:\conan\library_env310\lib\site-packages\git\cmd.py", line 1329, in _parse_object_header
    raise ValueError("SHA could not be resolved, git returned: %r" % (header_line.strip()))
ValueError: SHA could not be resolved, git returned: b''