python/cherry-picker

breaks on dry cherry-picking for multiple branches

mcepl opened this issue ยท 1 comments

mcepl commented

This happened to me on the freshly upgraded openSUSE/Tumbleweed:

tumbleweed-pkg~/r/cpython (3.9)$ python3 -mpip install -U cherry_picker@git+https://github.com/python/cherry-picker.git
Defaulting to user installation because normal site-packages is not writeable
Collecting cherry_picker@ git+https://github.com/python/cherry-picker.git
  Cloning https://github.com/python/cherry-picker.git to /tmp/pip-install-jzzbsfql/cherry-picker_cfe6f82ef02c43ad8cc54ccd332ba7e4
  Running command git clone --filter=blob:none --quiet https://github.com/python/cherry-picker.git /tmp/pip-install-jzzbsfql/cherry-picker_cfe6f82ef02c43ad8cc54ccd332ba7e4
  Resolved https://github.com/python/cherry-picker.git to commit 3e48d193d8ae19001883a25ccb825c39a7f36522
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: click>=6.0 in /usr/lib/python3.11/site-packages (from cherry_picker@ git+https://github.com/python/cherry-picker.git) (8.1.3)
Requirement already satisfied: gidgethub in /home/matej/.local/lib/python3.11/site-packages (from cherry_picker@ git+https://github.com/python/cherry-picker.git) (5.3.0)
Requirement already satisfied: requests in /usr/lib/python3.11/site-packages (from cherry_picker@ git+https://github.com/python/cherry-picker.git) (2.31.0)
Requirement already satisfied: uritemplate>=3.0.1 in /usr/lib/python3.11/site-packages (from gidgethub->cherry_picker@ git+https://github.com/python/cherry-picker.git) (4.1.1)
Requirement already satisfied: PyJWT[crypto]>=2.4.0 in /usr/lib/python3.11/site-packages (from gidgethub->cherry_picker@ git+https://github.com/python/cherry-picker.git) (2.7.0)
Requirement already satisfied: certifi>=2017.4.17 in /usr/lib/python3.11/site-packages (from requests->cherry_picker@ git+https://github.com/python/cherry-picker.git) (2023.5.7)
Requirement already satisfied: charset_normalizer<4,>=2 in /usr/lib/python3.11/site-packages (from requests->cherry_picker@ git+https://github.com/python/cherry-picker.git) (3.1.0)
Requirement already satisfied: idna<4,>=2.5 in /usr/lib/python3.11/site-packages (from requests->cherry_picker@ git+https://github.com/python/cherry-picker.git) (3.4)
Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/lib/python3.11/site-packages (from requests->cherry_picker@ git+https://github.com/python/cherry-picker.git) (2.0.3)
Requirement already satisfied: cryptography>=3.4.0 in /usr/lib64/python3.11/site-packages (from PyJWT[crypto]>=2.4.0->gidgethub->cherry_picker@ git+https://github.com/python/cherry-picker.git) (41.0.1)
Requirement already satisfied: cffi>=1.12 in /usr/lib64/python3.11/site-packages (from cryptography>=3.4.0->PyJWT[crypto]>=2.4.0->gidgethub->cherry_picker@ git+https://github.com/python/cherry-picker.git) (1.15.1)
Requirement already satisfied: pycparser in /usr/lib/python3.11/site-packages (from cffi>=1.12->cryptography>=3.4.0->PyJWT[crypto]>=2.4.0->gidgethub->cherry_picker@ git+https://github.com/python/cherry-picker.git) (2.21)
tumbleweed-pkg~/r/cpython (3.9)$ cherry_picker --dry-run 18dfbd035775c15533d13a98e56b1d2bf5c65f00 3.9 3.10 3.11
๐Ÿ ๐Ÿ’ โ›
Dry run requested, listing expected command sequence
  dry-run: git remote get-url upstream
  dry-run: git fetch upstream --no-tags
Now backporting '18dfbd035775c15533d13a98e56b1d2bf5c65f00' into '3.11'
  dry-run: git remote get-url upstream
  dry-run: git checkout -b backport-18dfbd0-3.11 upstream/3.11
  dry-run: git cherry-pick -x 18dfbd035775c15533d13a98e56b1d2bf5c65f00

  dry-run: git show -s --format=%B 18dfbd035775c15533d13a98e56b1d2bf5c65f00
Traceback (most recent call last):
  File "/home/matej/.bin/cherry_picker", line 8, in <module>
    sys.exit(cherry_pick_cli())
             ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/matej/.local/lib/python3.11/site-packages/cherry_picker/cherry_picker.py", line 645, in cherry_pick_cli
    cherry_picker.backport()
  File "/home/matej/.local/lib/python3.11/site-packages/cherry_picker/cherry_picker.py", line 387, in backport
    commit_message = self.amend_commit_message(cherry_pick_branch)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/matej/.local/lib/python3.11/site-packages/cherry_picker/cherry_picker.py", line 269, in amend_commit_message
    updated_commit_message = f"""{commit_prefix}{self.get_commit_message(self.commit_sha1)}
                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/matej/.local/lib/python3.11/site-packages/cherry_picker/cherry_picker.py", line 211, in get_commit_message
    message = self.run_cmd(cmd).strip()
              ^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'strip'

This should be fixed by #75.