softwarefactory-project / rdopkg

power to the packagers
Apache License 2.0
28 stars 21 forks source link

"patch" crashes when an existing .patch file is not from git-format-patch #99

Closed ktdreyer closed 7 years ago

ktdreyer commented 7 years ago

Seeing the following crash with master (4dd0bef9b99a409ff59055a48526b31e778019ef)

$ rdopkg patch
## get_package_env
## ensure_patches_branch
## get_patches_branch
git update-ref refs/heads/ceph-2-rhel-patches refs/remotes/patches/ceph-2-rhel-patches
## check_new_patches
Traceback (most recent call last):
  File "/home/kdreyer/dev/rdopkg/venv/bin/rdopkg", line 9, in <module>
    load_entry_point('rdopkg', 'console_scripts', 'rdopkg')()
  File "/home/kdreyer/dev/rdopkg/rdopkg/cli.py", line 46, in main
    sys.exit(rdopkg(*cargs))
  File "/home/kdreyer/dev/rdopkg/rdopkg/cli.py", line 38, in rdopkg
    return shell.run(runner, cargs=cargs, version=VERSION)
  File "/home/kdreyer/dev/rdopkg/rdopkg/shell.py", line 84, in run
    action_runner.engage()
  File "/home/kdreyer/dev/rdopkg/rdopkg/core.py", line 194, in engage
    new_args = self.action_manager.run_action(step, self.args)
  File "/home/kdreyer/dev/rdopkg/rdopkg/action.py", line 208, in run_action
    return action_fun(*fun_args)
  File "/home/kdreyer/dev/rdopkg/rdopkg/actions/distgit/actions.py", line 515, in check_new_patches
    if helpers.is_same_hash(hash, old_hash):
  File "/home/kdreyer/dev/rdopkg/rdopkg/helpers.py", line 86, in is_same_hash
    if h1 == h2 or h1.startswith(h2) or h2.startswith(h1):
TypeError: startswith first arg must be str, unicode, or tuple, not NoneType
ktdreyer commented 7 years ago

I should mention that in this case the ceph-2-rhel-patches branch was modified such that the last couple of commits were deleted and that was all - none were added.

ktdreyer commented 7 years ago

I found that this crash happens because I have an additional .patch file at the root of my dist-git tree that lacks the standard headers that git-format-patch creates. specfile.get_patches_from_files() returns None for the hash in that case.

ktdreyer commented 7 years ago

This is fallout from the fact that we have to occasionally ship .patch files for Git submodules :(

https://review.rdoproject.org/r/4533