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

Sometimes, an imprecise branch reference can't be resolved during continuation #155

Open
webknjaz opened this issue Feb 10, 2025 · 0 comments Β· May be fixed by #156
Open

Sometimes, an imprecise branch reference can't be resolved during continuation #155

webknjaz opened this issue Feb 10, 2025 · 0 comments Β· May be fixed by #156

Comments

@webknjaz
Copy link
Contributor

I've hit a conflict, fixed it re-ran cherry-picker with --continue and got a traceback + an invalid state in the config:

$ uvx --from cherry-picker cherry_picker --continue
🐍 πŸ’ ⛏
Traceback (most recent call last):
  File "~/.cache/uv/archive-v0/EI4uSp-Fsr1kEx0L58PRM/bin/cherry_picker", line 10, in <module>
    sys.exit(cherry_pick_cli())
             ~~~~~~~~~~~~~~~^^
  File "~/.cache/uv/archive-v0/EI4uSp-Fsr1kEx0L58PRM/lib/python3.13/site-packages/click/core.py", line 1161, in __call__
    return self.main(*args, **kwargs)
           ~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "~/.cache/uv/archive-v0/EI4uSp-Fsr1kEx0L58PRM/lib/python3.13/site-packages/click/core.py", line 1082, in main
    rv = self.invoke(ctx)
  File "~/.cache/uv/archive-v0/EI4uSp-Fsr1kEx0L58PRM/lib/python3.13/site-packages/click/core.py", line 1443, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/.cache/uv/archive-v0/EI4uSp-Fsr1kEx0L58PRM/lib/python3.13/site-packages/click/core.py", line 788, in invoke
    return __callback(*args, **kwargs)
  File "~/.cache/uv/archive-v0/EI4uSp-Fsr1kEx0L58PRM/lib/python3.13/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "~/.cache/uv/archive-v0/EI4uSp-Fsr1kEx0L58PRM/lib/python3.13/site-packages/cherry_picker/cherry_picker.py", line 855, in cherry_pick_cli
    cherry_picker.continue_cherry_pick()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "~/.cache/uv/archive-v0/EI4uSp-Fsr1kEx0L58PRM/lib/python3.13/site-packages/cherry_picker/cherry_picker.py", line 639, in continue_cherry_pick
    commits = get_commits_from_backport_branch(base)
  File "~/.cache/uv/archive-v0/EI4uSp-Fsr1kEx0L58PRM/lib/python3.13/site-packages/cherry_picker/cherry_picker.py", line 965, in get_commits_from_backport_branch
    output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
  File "~/.pyenv/versions/3.13.0/lib/python3.13/subprocess.py", line 472, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
           ~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
               **kwargs).stdout
               ^^^^^^^^^
  File "~/.pyenv/versions/3.13.0/lib/python3.13/subprocess.py", line 577, in run
    raise CalledProcessError(retcode, process.args,
                             output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['git', 'log', '--format=%H', 'stable-2.14..']' returned non-zero exit status 128.

$ uvx --from cherry-picker cherry_picker --continue
🐍 πŸ’ ⛏
Run state cherry-picker.state=CONTINUATION_STARTED in Git config is not known.
Perhaps it has been set by a newer version of cherry-picker. Try upgrading.
Valid states are: BACKPORT_PAUSED, UNSET. If this looks suspicious, raise an issue at https://github.com/python/cherry-picker/issues/new.
As the last resort you can reset the runtime state stored in Git config using the following command: `git config --local --remove-section cherry-picker`

Running that Git command revealed the inability of Git to resolve the stable-2.14 reference, while it is perfectly fine resolving the remote pointer origin/stable-2.14:

$ git log --format='%H' stable-2.14..
fatal: ambiguous argument 'stable-2.14..': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

$ git log --format='%H' stable-2.14.. --
fatal: bad revision 'stable-2.14..'

$ git log --format='%H' origin/stable-2.14..

This seems to be easily fixable by passing a better identifier to get_commits_from_backport_branch().

webknjaz added a commit to webknjaz/cherry_picker that referenced this issue Feb 10, 2025
Previously, the `git log` command would run against an unresolved
branch reference which might point to the wrong thing locally. This
patch makes it more predictable by specifying the exact remote branch.

Fixes python#155.
@webknjaz webknjaz linked a pull request Feb 10, 2025 that will close this issue
@webknjaz webknjaz changed the title Sometimes, old broken repos can't look up an imprecise branch reference, breaking continuation Sometimes, an imprecise branch reference can't be resolved during continuation Feb 10, 2025
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 a pull request may close this issue.

1 participant