-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Respect existing trailers (including co-author lines) when backporting (
#46)
- Loading branch information
Showing
2 changed files
with
128 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -538,6 +538,96 @@ def test_normalize_short_commit_message(): | |
) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"commit_message,expected_commit_message", | ||
( | ||
# ensure existing co-author is retained | ||
( | ||
"""Fix broken `Show Source` links on documentation pages (GH-3113) | ||
Co-authored-by: PR Co-Author <[email protected]>""", | ||
"""[3.6] Fix broken `Show Source` links on documentation pages (GH-3113) | ||
(cherry picked from commit b9ff498793611d1c6a9b99df464812931a1e2d69) | ||
Co-authored-by: PR Author <[email protected]> | ||
Co-authored-by: PR Co-Author <[email protected]>""", | ||
), | ||
# ensure co-author trailer is not duplicated | ||
( | ||
"""Fix broken `Show Source` links on documentation pages (GH-3113) | ||
Co-authored-by: PR Author <[email protected]>""", | ||
"""[3.6] Fix broken `Show Source` links on documentation pages (GH-3113) | ||
(cherry picked from commit b9ff498793611d1c6a9b99df464812931a1e2d69) | ||
Co-authored-by: PR Author <[email protected]>""", | ||
), | ||
# ensure message is formatted properly when original commit is short | ||
( | ||
"Fix broken `Show Source` links on documentation pages (GH-3113)", | ||
"""[3.6] Fix broken `Show Source` links on documentation pages (GH-3113) | ||
(cherry picked from commit b9ff498793611d1c6a9b99df464812931a1e2d69) | ||
Co-authored-by: PR Author <[email protected]>""", | ||
), | ||
# ensure message is formatted properly when original commit is long | ||
( | ||
"""Fix broken `Show Source` links on documentation pages (GH-3113) | ||
The `Show Source` was broken because of a change made in sphinx 1.5.1 | ||
In Sphinx 1.4.9, the sourcename was "index.txt". | ||
In Sphinx 1.5.1+, it is now "index.rst.txt".""", | ||
"""[3.6] Fix broken `Show Source` links on documentation pages (GH-3113) | ||
The `Show Source` was broken because of a change made in sphinx 1.5.1 | ||
In Sphinx 1.4.9, the sourcename was "index.txt". | ||
In Sphinx 1.5.1+, it is now "index.rst.txt". | ||
(cherry picked from commit b9ff498793611d1c6a9b99df464812931a1e2d69) | ||
Co-authored-by: PR Author <[email protected]>""", | ||
), | ||
# ensure message is formatted properly when original commit is long | ||
# and it has a co-author | ||
( | ||
"""Fix broken `Show Source` links on documentation pages (GH-3113) | ||
The `Show Source` was broken because of a change made in sphinx 1.5.1 | ||
In Sphinx 1.4.9, the sourcename was "index.txt". | ||
In Sphinx 1.5.1+, it is now "index.rst.txt". | ||
Co-authored-by: PR Co-Author <[email protected]>""", | ||
"""[3.6] Fix broken `Show Source` links on documentation pages (GH-3113) | ||
The `Show Source` was broken because of a change made in sphinx 1.5.1 | ||
In Sphinx 1.4.9, the sourcename was "index.txt". | ||
In Sphinx 1.5.1+, it is now "index.rst.txt". | ||
(cherry picked from commit b9ff498793611d1c6a9b99df464812931a1e2d69) | ||
Co-authored-by: PR Author <[email protected]> | ||
Co-authored-by: PR Co-Author <[email protected]>""", | ||
), | ||
), | ||
) | ||
def test_get_updated_commit_message_with_trailers(commit_message, expected_commit_message): | ||
cherry_pick_branch = "backport-22a594a-3.6" | ||
commit = "b9ff498793611d1c6a9b99df464812931a1e2d69" | ||
|
||
with mock.patch("cherry_picker.cherry_picker.validate_sha", return_value=True): | ||
cherry_picker = CherryPicker("origin", commit, []) | ||
|
||
with mock.patch( | ||
"cherry_picker.cherry_picker.validate_sha", return_value=True | ||
), mock.patch.object( | ||
cherry_picker, "get_commit_message", return_value=commit_message | ||
), mock.patch( | ||
"cherry_picker.cherry_picker.get_author_info_from_short_sha", | ||
return_value="PR Author <[email protected]>", | ||
): | ||
updated_commit_message = cherry_picker.get_updated_commit_message(cherry_pick_branch) | ||
|
||
assert updated_commit_message == expected_commit_message | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"input_path", ("/some/path/without/revision", "HEAD:some/non-existent/path") | ||
) | ||
|