optittm / bugprediction

A CLI tool to assess the risk of releasing your next version. Can generate a comprehensive dataset for testing your bug prediction models.
MIT License
0 stars 1 forks source link

Error: SHA could not be resolved #35

Open Creadeyh opened 1 year ago

Creadeyh commented 1 year ago

When using the populate command on the Python project https://github.com/alievk/avatarify-python we get this error:

Traceback (most recent call last): File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\main.py", line 403, in cli(obj={}) File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\venv\Lib\site-packages\click\core.py", line 764, in call return self.main(args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\venv\Lib\site-packages\click\core.py", line 717, in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\venv\Lib\site-packages\click\core.py", line 1137, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\venv\Lib\site-packages\click\core.py", line 956, in invoke return ctx.invoke(self.callback, ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\venv\Lib\site-packages\click\core.py", line 555, in invoke return callback(args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\venv\Lib\site-packages\click\decorators.py", line 17, in new_func return f(get_current_context(), *args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "src/dependency_injector/_cwiring.pyx", line 28, in dependency_injector._cwiring._get_sync_patched._patched File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\main.py", line 296, in populate
git.populate_db(skip_versions) File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\connectors\git.py", line 135, in populate_db self.create_commits_from_repo() File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\utils\timeit.py", line 9, in timeit_wrapper result = func(
args,
kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\connectors\git.py", line 95, in create_commits_from_repo dmm_unit_size=git_commit.dmm_unit_size, ^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\venv\Lib\site-packages\pydriller\domain\commit.py", line 797, in dmm_unit_size return self._delta_maintainability(DMMProperty.UNIT_SIZE) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\venv\Lib\site-packages\pydriller\domain\commit.py", line 845, in _delta_maintainability delta_profile = self._delta_risk_profile(dmm_prop) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\venv\Lib\site-packages\pydriller\domain\commit.py", line 863, in _delta_risk_profile mod for mod in self.modified_files if mod.language_supported ^^^^^^^^^^^^^^^^^^^ File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\venv\Lib\site-packages\pydriller\domain\commit.py", line 716, in modified_files return self._parse_diff(diff_index) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\venv\Lib\site-packages\pydriller\domain\commit.py", line 728, in _parse_diff "content": self._get_undecoded_content(diff.b_blob), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\venv\Lib\site-packages\pydriller\domain\commit.py", line 752, in _get_undecoded_content return blob.data_stream.read() if blob is not None else None ^^^^^^^^^^^^^^^^ File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\venv\Lib\site-packages\git\objects\base.py", line 142, in data_stream return self.repo.odb.stream(self.binsha) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\venv\Lib\site-packages\git\db.py", line 45, in stream hexsha, typename, size, stream = self._git.stream_object_data(bin_to_hex(binsha)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\venv\Lib\site-packages\git\cmd.py", line 1400, in stream_object_data hexsha, typename, size = self.get_object_header(cmd, ref) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\venv\Lib\site-packages\git\cmd.py", line 1370, in get_object_header return self._parse_object_header(cmd.stdout.readline()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\venv\Lib\site-packages\git\cmd.py", line 1331, in _parse_object_header raise ValueError("SHA %s could not be resolved, git returned: %r" % (tokens[0], header_line.strip()))
ValueError: SHA b'72a32a67dee3a67dff76f565551907a2fc7e88e6' could not be resolved, git returned: b'72a32a67dee3a67dff76f565551907a2fc7e88e6 missing'

Creadeyh commented 1 year ago

Fixed the first issue in #36 The error was caused by a submodule commit within an avatarify commit (ex: commit) which couldn't be accessed by PyDriller when calculating the DMM metrics. As these metrics are often returning NULL anyway, we are skipping them for that particular commit when the error is encountered

Creadeyh commented 1 year ago

Same error is raised when calculating the versions' churn. Since we just call PyDriller's CodeChurn class on the whole version, we can't just skip the troublesome commits. As stated in #36 the issue has been submitted on PyDriller's GitHub https://github.com/ishepard/pydriller/issues/260 and I am waiting for a solution from them.

Creadeyh commented 1 year ago

Same error is raised when calling pydriller.Commit.modified_files

Creadeyh commented 1 year ago

While waiting for a fix from PyDriller, BugPrediction will just skip the problematic commits/versions and leave a warning log. This issue with submodules will also be added in the readme's limitations