GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix detection of upstream version branches with continue by abadger · Pull Request #265 · python/core-workflow

Conversation

@abadger

@abadger abadger commented Jun 16, 2018

Copy link
Copy Markdown
Contributor

cherry_picker has recently grown support for prefixed version branches
(like stable-2.6). The --continue support had a bug with those branches
where it wouldn't account for the fact that those branches could have
extra dashes in them and thus mixing branch name with sha.

This commit should fix those situations.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@abadger
Fix detection of upstream version branches with continue
c5f7faf
cherry_picker has recently grown support for prefixed version branches
(like stable-2.6).  The --continue support had a bug with those branches
where it wouldn't account for the fact that those branches could have
extra dashes in them and thus mixing branch name with sha.

This commit should fix those situations.
@abadger
abadger requested a review from Mariatta as a code owner June 16, 2018 20:13
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Jun 16, 2018
@abadger abadger mentioned this pull request Jun 16, 2018
🚸 🐍 🍒 ⛏ Integrate cherry picker ansible/ansible#41403
Merged
webknjaz
webknjaz approved these changes Jun 16, 2018
View reviewed changes
@webknjaz

webknjaz commented Jun 16, 2018

Copy link
Copy Markdown
Member

@abadger You need to take into account case when a user might run --continue from a different branch:

=================================== FAILURES ===================================
______________________ test_get_base_branch_without_dash _______________________
    def test_get_base_branch_without_dash():
        cherry_pick_branch ='master'
>       result = get_base_branch(cherry_pick_branch)
cherry_picker/test.py:43: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
cherry_pick_branch = 'master'
    def get_base_branch(cherry_pick_branch):
        """
        return '2.7' from 'backport-sha-2.7'
        """
>       prefix, sha, base_branch = cherry_pick_branch.split('-', 2)
E       ValueError: not enough values to unpack (expected 3, got 1)
cherry_picker/cherry_picker.py:425: ValueError
===================== 1 failed, 27 passed in 0.35 seconds ======================
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@abadger

abadger commented Jun 16, 2018

Copy link
Copy Markdown
Contributor Author

Ah... I thought rpartition traced back in that case too but I see now it always returns a three tuple.

I can replicate the previous behaviour here but I'm not sure... is that actually sensible behaviour? From where it's being called, I think that this would cause other bugs.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@abadger

abadger commented Jun 16, 2018

Copy link
Copy Markdown
Contributor Author

So the two places that get_base_branch is currently called from are:

  • https://github.com/python/core-workflow/blob/master/cherry_picker/cherry_picker/cherry_picker.py#L330
    This is on the --continue codepath. The very next line will traceback if there's no dash in the branch that we pass into get_base_branch.
  • https://github.com/python/core-workflow/blob/master/cherry_picker/cherry_picker/cherry_picker.py#L184 In this case it won't traceback later. However, the branch that it's passed in this case is generated here: https://github.com/python/core-workflow/blob/master/cherry_picker/cherry_picker/cherry_picker.py#L277
    which in turn is generated by this function: https://github.com/python/core-workflow/blob/master/cherry_picker/cherry_picker/cherry_picker.py#L98 So in that case it will always be a branch name with at least two dashes.

Thinking about this more, it feels like this function is assuming that it's taking a string of a known format, assigning semantic meaning to pieces of that string based on their position inside of it, and then returning the value that corresponds to one of those meanings. If so, it feels right that the code should raise a ValueError if the string does not conform to the format... Otherwise how would we know what portion of the string was the base branch? Is it all of it? Is it the first piece? The last piece? Or perhaps none of those because we weren't given a string containing the base branch at all?

So I think the test is wrong but perhaps there's some other use case for this code that I am not aware of? @Mariatta ? Input from you?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@abadger

abadger commented Jun 16, 2018

Copy link
Copy Markdown
Contributor Author

I've pushed a change to the test cases which removes the "no_dash" test and adds one for "dashes in the base branch".

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@abadger
Update tests to check for base branches which have dashes in them.
f90d993
@abadger
abadger force-pushed the fix-continue-with-prefixed-version-branches branch from 04e31d5 to f90d993 Compare June 16, 2018 22:32
@webknjaz

webknjaz commented Jun 16, 2018

Copy link
Copy Markdown
Member

I can replicate the previous behaviour here but I'm not sure... is that actually sensible behaviour? From where it's being called, I think that this would cause other bugs.

Git itself is a very stateful tool, so it's expected that when you rely on it there's some restrictions.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

abadger added a commit to abadger/core-workflow that referenced this pull request Jun 16, 2018
@abadger
Validate a branch that we parse when running cherry_picker --continue
b42b8a9
When running cherry_picker --continue we count on being able to get
certain information from the branch's name which cherry_picker
constructed earlier.  Verify as best we can that the branch name is one
which cherry_picker could have constructed.

Relies on the changes here: python#265
(which does the work of one of the validations)
@abadger abadger mentioned this pull request Jun 16, 2018
Validate a branch that we parse when running cherry_picker --continue #266
Merged
@abadger

abadger commented Jun 16, 2018

Copy link
Copy Markdown
Contributor Author

My question doesn't come from what git does; it comes from what cherry-picker is doing with this branch name. AFAICT, the branch name has to be one that we created (with the three dashes), otherwise the present code will fail. So it seems like the current test that no dashes works is testing something that we'll never want the code itself to do.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@abadger abadger closed this Jun 19, 2018
@abadger abadger reopened this Jun 19, 2018
abadger added a commit to abadger/core-workflow that referenced this pull request Jun 22, 2018
@abadger
Validate a branch that we parse when running cherry_picker --continue
b88b167
When running cherry_picker --continue we count on being able to get
certain information from the branch's name which cherry_picker
constructed earlier.  Verify as best we can that the branch name is one
which cherry_picker could have constructed.

Relies on the changes here: python#265
(which does the work of one of the validations)
webknjaz
webknjaz approved these changes Jun 22, 2018
View reviewed changes
@webknjaz

webknjaz commented Jul 2, 2018

Copy link
Copy Markdown
Member

@Mariatta this PR looks ready :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Mariatta
Mariatta approved these changes Jul 9, 2018
View reviewed changes
@Mariatta

Mariatta commented Jul 9, 2018

Copy link
Copy Markdown
Member

Sorry for the delay in responding to this! 🙇‍♀️
The original implementation was based on CPython's branch names that doesn't include dashes, so it didn't handle ansible's situation.
Thanks for catching and fixing this!

webknjaz reacted with hooray emoji
All reactions
  • 🎉 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Mariatta
Mariatta merged commit ff8a587 into python:master Jul 9, 2018
abadger added a commit to abadger/core-workflow that referenced this pull request Jul 9, 2018
@abadger
Validate a branch that we parse when running cherry_picker --continue
113eb21
When running cherry_picker --continue we count on being able to get
certain information from the branch's name which cherry_picker
constructed earlier.  Verify as best we can that the branch name is one
which cherry_picker could have constructed.

Relies on the changes here: python#265
(which does the work of one of the validations)
@abadger
abadger deleted the fix-continue-with-prefixed-version-branches branch July 18, 2018 19:32
@Mariatta Mariatta mentioned this pull request Aug 3, 2018
Please update the changelog for cherry_picker #279
Closed
@Mariatta Mariatta added the cherry_picker.py label Aug 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@webknjaz webknjaz webknjaz approved these changes
@Mariatta Mariatta Mariatta approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

cherry_picker.py CLA signed

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@abadger @webknjaz @Mariatta @the-knights-who-say-ni
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.