Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,22 @@ git:
depth: false


dist: xenial
dist: focal
cache: pip


language: python
python:
- "3.9"
- "3.8"
- "3.7"
- "3.6"
- "nightly" # currently, it's 3.8-dev
- "nightly" # currently, it's 3.10

matrix:
allow_failures:
- python: "nightly"
dist: focal

install:
- python -m pip install --upgrade flit pip
Expand Down
4 changes: 2 additions & 2 deletions cherry_picker/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""Backport CPython changes from master to maintenance branches."""
__version__ = '1.3.3.dev1'
"""Backport CPython changes from main to maintenance branches."""
__version__ = "2.0.0.dev1"
2 changes: 1 addition & 1 deletion cherry_picker/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .cherry_picker import cherry_pick_cli

if __name__ == '__main__':
if __name__ == "__main__":
cherry_pick_cli()
2 changes: 1 addition & 1 deletion cherry_picker/cherry_picker.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"repo": "cpython",
"check_sha": "7f777ed95a19224294949e1b4ce56bbffcb1fe9f",
"fix_commit_msg": True,
"default_branch": "master",
"default_branch": "main",
}
)

Expand Down
22 changes: 13 additions & 9 deletions cherry_picker/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def changedir(d):

@pytest.fixture
def git_init():
git_init_cmd = "git", "init", "."
git_init_cmd = "git", "init", "--initial-branch=main", "."
return lambda: subprocess.run(git_init_cmd, check=True)


Expand Down Expand Up @@ -143,8 +143,8 @@ def test_get_base_branch_invalid(subprocess_check_output, cherry_pick_branch):

@mock.patch("subprocess.check_output")
def test_get_current_branch(subprocess_check_output):
subprocess_check_output.return_value = b"master"
assert get_current_branch() == "master"
subprocess_check_output.return_value = b"main"
assert get_current_branch() == "main"


@mock.patch("subprocess.check_output")
Expand Down Expand Up @@ -368,7 +368,7 @@ def test_load_partial_config(tmp_git_repo_dir, git_add, git_commit):
"repo": "core-workfolow",
"team": "python",
"fix_commit_msg": True,
"default_branch": "master",
"default_branch": "main",
},
)

Expand Down Expand Up @@ -608,15 +608,19 @@ def test_cherry_pick(tmp_git_repo_dir, git_add, git_branch, git_commit, git_chec
cherry_picker.cherry_pick()


def test_cherry_pick_fail(tmp_git_repo_dir,):
def test_cherry_pick_fail(
tmp_git_repo_dir,
):
with mock.patch("cherry_picker.cherry_picker.validate_sha", return_value=True):
cherry_picker = CherryPicker("origin", "xxx", [])

with pytest.raises(CherryPickException, match="^Error cherry-pick xxx.$"):
cherry_picker.cherry_pick()


def test_get_state_and_verify_fail(tmp_git_repo_dir,):
def test_get_state_and_verify_fail(
tmp_git_repo_dir,
):
class tested_state:
name = "invalid_state"

Expand Down Expand Up @@ -648,7 +652,7 @@ def test_push_to_remote_fail(tmp_git_repo_dir):
with mock.patch("cherry_picker.cherry_picker.validate_sha", return_value=True):
cherry_picker = CherryPicker("origin", "xxx", [])

cherry_picker.push_to_remote("master", "backport-branch-test")
cherry_picker.push_to_remote("main", "backport-branch-test")
assert get_state() == WORKFLOW_STATES.PUSHING_TO_REMOTE_FAILED


Expand All @@ -659,7 +663,7 @@ def test_push_to_remote_interactive(tmp_git_repo_dir):
with mock.patch.object(cherry_picker, "run_cmd"), mock.patch.object(
cherry_picker, "open_pr"
), mock.patch.object(cherry_picker, "get_pr_url", return_value="https://pr_url"):
cherry_picker.push_to_remote("master", "backport-branch-test")
cherry_picker.push_to_remote("main", "backport-branch-test")
assert get_state() == WORKFLOW_STATES.PR_OPENING


Expand All @@ -671,7 +675,7 @@ def test_push_to_remote_botflow(tmp_git_repo_dir, monkeypatch):
with mock.patch.object(cherry_picker, "run_cmd"), mock.patch.object(
cherry_picker, "create_gh_pr"
):
cherry_picker.push_to_remote("master", "backport-branch-test")
cherry_picker.push_to_remote("main", "backport-branch-test")
assert get_state() == WORKFLOW_STATES.PR_CREATING


Expand Down
24 changes: 13 additions & 11 deletions readme.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Usage (from a cloned CPython directory) ::
About
=====

This tool is used to backport CPython changes from ``master`` into one or more
This tool is used to backport CPython changes from ``main`` into one or more
of the maintenance branches (``3.6``, ``3.5``, ``2.7``).

``cherry_picker`` can be configured to backport other projects with similar
Expand Down Expand Up @@ -76,10 +76,10 @@ Commit sha1
-----------

The commit sha1 for cherry-picking is the squashed commit that was merged to
the ``master`` branch. On the merged pull request, scroll to the bottom of the
the ``main`` branch. On the merged pull request, scroll to the bottom of the
page. Find the event that says something like::

<coredeveloper> merged commit <commit_sha1> into python:master <sometime> ago.
<coredeveloper> merged commit <commit_sha1> into python:main <sometime> ago.

By following the link to ``<commit_sha1>``, you will get the full commit hash.
Use the full commit hash for ``cherry_picker.py``.
Expand Down Expand Up @@ -136,7 +136,7 @@ Available config options::

repo Project's default branch name,
e.g "devel" for https://github.com/ansible/ansible
("master" by default)
("main" by default)


To customize the tool for used by other project:
Expand Down Expand Up @@ -190,13 +190,13 @@ What this will do:
(venv) $ git checkout -b backport-6de2b78-3.5 upstream/3.5
(venv) $ git cherry-pick -x 6de2b7817f-some-commit-sha1-d064
(venv) $ git push origin backport-6de2b78-3.5
(venv) $ git checkout master
(venv) $ git checkout main
(venv) $ git branch -D backport-6de2b78-3.5

(venv) $ git checkout -b backport-6de2b78-3.6 upstream/3.6
(venv) $ git cherry-pick -x 6de2b7817f-some-commit-sha1-d064
(venv) $ git push origin backport-6de2b78-3.6
(venv) $ git checkout master
(venv) $ git checkout main
(venv) $ git branch -D backport-6de2b78-3.6

In case of merge conflicts or errors, the following message will be displayed::
Expand Down Expand Up @@ -226,14 +226,14 @@ steps it would execute without actually executing any of them. For example::
dry_run: git cherry-pick -x 1e32a1be4a1705e34011770026cb64ada2d340b5
dry_run: git push pr backport-1e32a1b-3.6
dry_run: Create new PR: https://github.com/python/cpython/compare/3.6...ncoghlan:backport-1e32a1b-3.6?expand=1
dry_run: git checkout master
dry_run: git checkout main
dry_run: git branch -D backport-1e32a1b-3.6
Now backporting '1e32a1be4a1705e34011770026cb64ada2d340b5' into '3.5'
dry_run: git checkout -b backport-1e32a1b-3.5 origin/3.5
dry_run: git cherry-pick -x 1e32a1be4a1705e34011770026cb64ada2d340b5
dry_run: git push pr backport-1e32a1b-3.5
dry_run: Create new PR: https://github.com/python/cpython/compare/3.5...ncoghlan:backport-1e32a1b-3.5?expand=1
dry_run: git checkout master
dry_run: git checkout main
dry_run: git branch -D backport-1e32a1b-3.5

`--pr-remote` option
Expand Down Expand Up @@ -291,7 +291,7 @@ The url of the pull request page looks similar to the following::
Press the ``Create Pull Request`` button.

Bedevere will then remove the ``needs backport to ...`` label from the original
pull request against ``master``.
pull request against ``main``.


Running Tests
Expand Down Expand Up @@ -329,15 +329,17 @@ in the directory where ``pyproject.toml`` exists::
.. |pypi status| image:: https://img.shields.io/pypi/v/cherry-picker.svg
:target: https://pypi.org/project/cherry-picker/

.. |travis status| image:: https://travis-ci.com/python/cherry-picker.svg?branch=master
.. |travis status| image:: https://travis-ci.com/python/cherry-picker.svg?branch=main
:target: https://travis-ci.com/python/cherry-picker

Changelog
=========

1.3.3 (in development)
2.0.0 (in development)
----------------------

- Support the ``main`` branch by default. To use a different default branch,
please configure it in the ``.cherry-picker.toml`` file.

1.3.2
-----
Expand Down