-
-
Notifications
You must be signed in to change notification settings - Fork 42
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
Allow specifying custom upstream remote name #35
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
500d3c2
Allow specifying custom upstream remote name
Jackenmen c9172a1
Add test
Jackenmen 3a569a1
Update readme
Jackenmen d4c956a
Merge branch 'main' into issue/19
Jackenmen 2ef9489
Merge branch 'main' into issue/19
Jackenmen ad6cc0d
Parametrize upstream_remote instead of weird ifs
Jackenmen 6fd172d
Add two more parametrization variants
Jackenmen d51701a
Merge branch 'main' into issue/19
Jackenmen 2ba3e18
Rephrase mention of `--upstream-remote` in README
Jackenmen a00318f
Error out early if remote does not exist
Jackenmen 16bd654
Test that cp.upstream errors on missing remote
Jackenmen 5c7266e
Use good-old private attribute instead of the fancy lru_cache
Jackenmen 935085b
Drop unnecessary f from f-string
Jackenmen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 | ||||
---|---|---|---|---|---|---|
|
@@ -57,6 +57,12 @@ def git_init(): | |||||
return lambda: subprocess.run(git_init_cmd, check=True) | ||||||
|
||||||
|
||||||
@pytest.fixture | ||||||
def git_remote(): | ||||||
git_remote_cmd = "git", "remote" | ||||||
return lambda *extra_args: (subprocess.run(git_remote_cmd + extra_args, check=True)) | ||||||
|
||||||
|
||||||
@pytest.fixture | ||||||
def git_add(): | ||||||
git_add_cmd = "git", "add" | ||||||
|
@@ -238,6 +244,62 @@ def test_get_cherry_pick_branch(os_path_exists, config): | |||||
assert cp.get_cherry_pick_branch("3.6") == "backport-22a594a-3.6" | ||||||
|
||||||
|
||||||
@pytest.mark.parametrize( | ||||||
"remote_name,upstream_remote", | ||||||
( | ||||||
("upstream", None), | ||||||
("upstream", "upstream"), | ||||||
("origin", None), | ||||||
("origin", "origin"), | ||||||
("python", "python"), | ||||||
), | ||||||
) | ||||||
def test_upstream_name(remote_name, upstream_remote, config, tmp_git_repo_dir, git_remote): | ||||||
git_remote("add", remote_name, "https://github.com/python/cpython.git") | ||||||
if remote_name != "origin": | ||||||
git_remote("add", "origin", "https://github.com/miss-islington/cpython.git") | ||||||
|
||||||
branches = ["3.6"] | ||||||
with mock.patch("cherry_picker.cherry_picker.validate_sha", return_value=True): | ||||||
cp = CherryPicker( | ||||||
"origin", | ||||||
"22a594a0047d7706537ff2ac676cdc0f1dcb329c", | ||||||
branches, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
config=config, | ||||||
upstream_remote=upstream_remote, | ||||||
) | ||||||
assert cp.upstream == remote_name | ||||||
|
||||||
|
||||||
@pytest.mark.parametrize( | ||||||
"remote_to_add,remote_name,upstream_remote", | ||||||
( | ||||||
(None, "upstream", None), | ||||||
("origin", "upstream", "upstream"), | ||||||
(None, "origin", None), | ||||||
("upstream", "origin", "origin"), | ||||||
("origin", "python", "python"), | ||||||
(None, "python", None), | ||||||
), | ||||||
) | ||||||
def test_error_on_missing_remote(remote_to_add, remote_name, upstream_remote, config, tmp_git_repo_dir, git_remote): | ||||||
git_remote("add", "some-remote-name", "https://github.com/python/cpython.git") | ||||||
if remote_to_add is not None: | ||||||
git_remote("add", remote_to_add, "https://github.com/miss-islington/cpython.git") | ||||||
|
||||||
branches = ["3.6"] | ||||||
with mock.patch("cherry_picker.cherry_picker.validate_sha", return_value=True): | ||||||
cp = CherryPicker( | ||||||
"origin", | ||||||
"22a594a0047d7706537ff2ac676cdc0f1dcb329c", | ||||||
branches, | ||||||
config=config, | ||||||
upstream_remote=upstream_remote, | ||||||
) | ||||||
with pytest.raises(ValueError): | ||||||
cp.upstream | ||||||
|
||||||
|
||||||
def test_get_pr_url(config): | ||||||
branches = ["3.6"] | ||||||
|
||||||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why assign to a variable if you can just pass it directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it's consistent with the rest of the code in this file. Or more truthfully... Because I copy-pasted one of the other test cases when making this one :) I'm indifferent to what's done here but I'll wait to change it until one of the maintainers requests it.