Skip to content

Commit 68bf6bf

Browse files
authored
Support the main branch by default. (#23)
* Initialize git with ``main`` as the default branch. * Use the `focal` dist on travis CI since it has git 2.28 * Update the documentation to refer to the ``main`` branch. * Allow failure in 3.10 Closes #21
1 parent 39e8d6d commit 68bf6bf

File tree

6 files changed

+38
-26
lines changed

6 files changed

+38
-26
lines changed

.travis.yml

+8-2
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,22 @@ git:
44
depth: false
55

66

7-
dist: xenial
7+
dist: focal
88
cache: pip
99

1010

1111
language: python
1212
python:
13+
- "3.9"
14+
- "3.8"
1315
- "3.7"
1416
- "3.6"
15-
- "nightly" # currently, it's 3.8-dev
17+
- "nightly" # currently, it's 3.10
1618

19+
matrix:
20+
allow_failures:
21+
- python: "nightly"
22+
dist: focal
1723

1824
install:
1925
- python -m pip install --upgrade flit pip

cherry_picker/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
"""Backport CPython changes from master to maintenance branches."""
2-
__version__ = '1.3.3.dev1'
1+
"""Backport CPython changes from main to maintenance branches."""
2+
__version__ = "2.0.0.dev1"

cherry_picker/__main__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from .cherry_picker import cherry_pick_cli
22

3-
if __name__ == '__main__':
3+
if __name__ == "__main__":
44
cherry_pick_cli()

cherry_picker/cherry_picker.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"repo": "cpython",
2626
"check_sha": "7f777ed95a19224294949e1b4ce56bbffcb1fe9f",
2727
"fix_commit_msg": True,
28-
"default_branch": "master",
28+
"default_branch": "main",
2929
}
3030
)
3131

cherry_picker/test.py

+13-9
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def changedir(d):
5252

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

5858

@@ -143,8 +143,8 @@ def test_get_base_branch_invalid(subprocess_check_output, cherry_pick_branch):
143143

144144
@mock.patch("subprocess.check_output")
145145
def test_get_current_branch(subprocess_check_output):
146-
subprocess_check_output.return_value = b"master"
147-
assert get_current_branch() == "master"
146+
subprocess_check_output.return_value = b"main"
147+
assert get_current_branch() == "main"
148148

149149

150150
@mock.patch("subprocess.check_output")
@@ -368,7 +368,7 @@ def test_load_partial_config(tmp_git_repo_dir, git_add, git_commit):
368368
"repo": "core-workfolow",
369369
"team": "python",
370370
"fix_commit_msg": True,
371-
"default_branch": "master",
371+
"default_branch": "main",
372372
},
373373
)
374374

@@ -608,15 +608,19 @@ def test_cherry_pick(tmp_git_repo_dir, git_add, git_branch, git_commit, git_chec
608608
cherry_picker.cherry_pick()
609609

610610

611-
def test_cherry_pick_fail(tmp_git_repo_dir,):
611+
def test_cherry_pick_fail(
612+
tmp_git_repo_dir,
613+
):
612614
with mock.patch("cherry_picker.cherry_picker.validate_sha", return_value=True):
613615
cherry_picker = CherryPicker("origin", "xxx", [])
614616

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

618620

619-
def test_get_state_and_verify_fail(tmp_git_repo_dir,):
621+
def test_get_state_and_verify_fail(
622+
tmp_git_repo_dir,
623+
):
620624
class tested_state:
621625
name = "invalid_state"
622626

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

651-
cherry_picker.push_to_remote("master", "backport-branch-test")
655+
cherry_picker.push_to_remote("main", "backport-branch-test")
652656
assert get_state() == WORKFLOW_STATES.PUSHING_TO_REMOTE_FAILED
653657

654658

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

665669

@@ -671,7 +675,7 @@ def test_push_to_remote_botflow(tmp_git_repo_dir, monkeypatch):
671675
with mock.patch.object(cherry_picker, "run_cmd"), mock.patch.object(
672676
cherry_picker, "create_gh_pr"
673677
):
674-
cherry_picker.push_to_remote("master", "backport-branch-test")
678+
cherry_picker.push_to_remote("main", "backport-branch-test")
675679
assert get_state() == WORKFLOW_STATES.PR_CREATING
676680

677681

readme.rst

+13-11
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Usage (from a cloned CPython directory) ::
1111
About
1212
=====
1313

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

1717
``cherry_picker`` can be configured to backport other projects with similar
@@ -76,10 +76,10 @@ Commit sha1
7676
-----------
7777

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

82-
<coredeveloper> merged commit <commit_sha1> into python:master <sometime> ago.
82+
<coredeveloper> merged commit <commit_sha1> into python:main <sometime> ago.
8383

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

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

141141

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

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

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

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

293293
Bedevere will then remove the ``needs backport to ...`` label from the original
294-
pull request against ``master``.
294+
pull request against ``main``.
295295

296296

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

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

335335
Changelog
336336
=========
337337

338-
1.3.3 (in development)
338+
2.0.0 (in development)
339339
----------------------
340340

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

342344
1.3.2
343345
-----

0 commit comments

Comments
 (0)