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

fix: add -c log.showsignature=false to all git log commands #75

Merged
merged 1 commit into from
Feb 6, 2024

Conversation

pdecat
Copy link
Contributor

@pdecat pdecat commented Feb 1, 2024

This PR is a follow up to #51 and resolves issues where log.showSignature = true is set in git config, e.g.:

# pipx install git+ssh://git@myhost/myrepo.git
  error: subprocess-exited-with-error

  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [36 lines of output]
      Traceback (most recent call last):
        File "/home/patrick/.local/pipx/shared/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/home/patrick/.local/pipx/shared/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/patrick/.local/pipx/shared/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 149, in prepare_metadata_for_build_wheel
          return hook(metadata_directory, config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-ndzkym2o/overlay/lib/python3.11/site-packages/poetry/core/masonry/api.py", line 42, in prepare_metadata_for_build_wheel
          poetry = Factory().create_poetry(Path(".").resolve(), with_groups=False)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-ndzkym2o/overlay/lib/python3.11/site-packages/poetry_dynamic_versioning/patch.py", line 26, in alt_poetry_create
          name = _get_and_apply_version(
                 ^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-ndzkym2o/overlay/lib/python3.11/site-packages/poetry_dynamic_versioning/__init__.py", line 608, in _get_and_apply_version
          version, instance = _get_version(config, name)
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-ndzkym2o/overlay/lib/python3.11/site-packages/poetry_dynamic_versioning/__init__.py", line 462, in _get_version
          serialized = version.serialize(
                       ^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-ndzkym2o/overlay/lib/python3.11/site-packages/dunamai/__init__.py", line 817, in serialize
          out = serialize_semver(base, pre=pre_parts, metadata=meta_parts)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-ndzkym2o/overlay/lib/python3.11/site-packages/dunamai/__init__.py", line 2131, in serialize_semver
          check_version(serialized, Style.SemVer)
        File "/tmp/pip-build-env-ndzkym2o/overlay/lib/python3.11/site-packages/dunamai/__init__.py", line 1991, in check_version
          raise ValueError(failure_message)
      ValueError: Version '0.35.1-post.4+gpg: Signature made Tue 21 Nov 2023 03:12:10 PM CET
      gpg:                using RSA key ******
      gpg: Good signature from "****** <******>" [unknown]
      gpg:                 aka "****** <******>" [unknown]
      gpg: WARNING: This key is not certified with a trusted signature!
      gpg:          There is no indication that the signature belongs to the owner.
      Primary key fingerprint: ******
      bab8748' does not conform to the Semantic Versioning style
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
Cannot determine package name from spec 'git+ssh://git@myhost/myrepo.git'. Check package spec for errors.

A work-around is to ignore the git configuration during installation:

GIT_CONFIG_GLOBAL=/dev/null pipx install git+ssh://git@myhost/myrepo.git

Signed-off-by: Patrick Decat pdecat@gmail.com

@mtkennerly
Copy link
Owner

Thanks for this!

One issue is that log.showsignature was added in Git 2.10.0, so we just need to add a condition based on the Git version (e.g., if git_version < [2, 10]). Dunamai tries to at least partially support versions as old as 1.8.2.3.

…t version is >= 2.10.0

Signed-off-by: Patrick Decat <pdecat@gmail.com>
@pdecat pdecat force-pushed the fix/git_log_no_show_signature branch from 946a037 to 9c49a84 Compare February 3, 2024 17:37
@pdecat
Copy link
Contributor Author

pdecat commented Feb 3, 2024

Hi @mtkennerly, done!

Note: git -c log.showsignature was already used without this exact version check, so it would have failed with git versions between v2.2 and v2.9.

Comment on lines +484 to +485
"git log --simplify-by-decoration --topo-order"
' --decorate=full {} "--format=%H%d"'.format(tag_branch)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's certainly room to improve this and avoid duplication, but I've seen this pattern used below, so I figured I'd stick to it.

Maybe extracting git log commands into a function would help.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A way more intrusive change would be to use something like https://github.com/jelmer/dulwich or https://github.com/gitpython-developers/GitPython to avoid having to deal with such details altogether.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can definitely try to reduce some of the duplication, but I think it's okay for now.

I'd like to keep Dunamai's dependencies pretty minimal; otherwise, yeah, Dulwich or GitPython could be nice.

@mtkennerly mtkennerly merged commit 1c50869 into mtkennerly:master Feb 6, 2024
12 checks passed
@pdecat pdecat deleted the fix/git_log_no_show_signature branch February 6, 2024 19:03
@mtkennerly mtkennerly added this to the v1.19.1 milestone Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants