Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Automatically hyperlink bpo- text. (#103)#121

Merged
Mariatta merged 4 commits into
python:masterpython/bedevere:masterfrom
storymode7:hyperlink-bpo-textstorymode7/bedevere:hyperlink-bpo-textCopy head branch name to clipboard
Jul 27, 2018
Merged

Automatically hyperlink bpo- text. (#103)#121
Mariatta merged 4 commits into
python:masterpython/bedevere:masterfrom
storymode7:hyperlink-bpo-textstorymode7/bedevere:hyperlink-bpo-textCopy head branch name to clipboard

Conversation

@storymode7

@storymode7 storymode7 commented Jul 14, 2018

Copy link
Copy Markdown
Contributor

Hey, This aims to fix #103 .
If anything needs any improvement please hint me, I'll fix it up in the best manner I can 😄
(I added the changes to bpo.py, if you find it inappropriate, please suggest where it'd suite better)

@codecov

codecov Bot commented Jul 14, 2018

Copy link
Copy Markdown

Codecov Report

Merging #121 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #121    +/-   ##
======================================
  Coverage     100%   100%            
======================================
  Files          20     20            
  Lines        1332   1482   +150     
  Branches       72     85    +13     
======================================
+ Hits         1332   1482   +150
Impacted Files Coverage Δ
tests/test_bpo.py 100% <100%> (ø) ⬆️
bedevere/bpo.py 100% <100%> (ø) ⬆️
bedevere/backport.py 100% <0%> (ø) ⬆️
tests/test_backport.py 100% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 44aff09...1840cf4. Read the comment docs.

@Mariatta Mariatta left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Great start. I have some nitpicky comments.
I also think the hyperlinking should be done when the PR is opened/edited.

Comment thread tests/test_bpo.py Outdated
data = {
"action": "created",
"comment": {
"url":"https://api.github.com/repos/blah/blah/issues/comments/123456",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space after "url":.
Same for the lines 302, 319, 320, 336, 337, 358, 359

Comment thread bedevere/bpo.py


@router.register("issue_comment", action="edited")
@router.register("issue_comment", action="created")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking that the hyperlinking should also be done on pull_request opened and edited events.
The body will be event.data["pull_request"]["body"] instead of event.data["comment"]["body"].
And the patch url to be used in line 93 will be event.data["pull_request"]["issue_url"].

@storymode7 storymode7 Jul 16, 2018

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reviewing! 🙂
Just a small question:
Wouldn't it be better if the bot hyperlinks bpo- text in the comment? As

  • the pull request body already contains the link of the issue.
  • Also, few (510 out of 7,525) PRs have bpo- text in the body.

Please correct me if I am wrong.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I meant to do this in both issue_comment and pull_request body.

The PR body already contains the link to the bpo that is mentioned in the PR title, and we should leave that as is.
I just think it would be nice to be also able to refer to other bpo tickets in the PR body.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. Thanks!
I get it now 🙂

Comment thread bedevere/bpo.py Outdated
\s*bpo-(?P<issue>{issue})\s*
</a>""".format(issue=issue),
re.VERBOSE)
# The following approach takes care of cases like bpo-123 [bpo-123]...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the comments here and in line 126 should be part of docstring instead of inline codes.

Comment thread bedevere/bpo.py Outdated
def create_hyperlink_in_comment_body(body):
new_body = ''
leftover_body = body
# Using infinite while loop as it supports updation of the string being

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer these comments as docstrings.

@storymode7 storymode7 force-pushed the hyperlink-bpo-text branch from 8810c56 to 436bdd4 Compare July 18, 2018 11:35
@storymode7 storymode7 force-pushed the hyperlink-bpo-text branch from 436bdd4 to 3c53aba Compare July 18, 2018 11:58

@Mariatta Mariatta left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks great. Just some other nitpicky things..

Comment thread bedevere/bpo.py Outdated


def create_hyperlink_in_comment_body(body):
"""Uses infinite loop for updating the string being searched dynamically"""

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing period at the end of the sentence.

Comment thread tests/test_bpo.py Outdated
@pytest.mark.asyncio
async def test_set_comment_body_success():
data = {
"action": "opened",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're only testing for the pull_request opened event.
Can you also test for the pull_request edited, issue_comment created, and issue_comment edited events?
Probably you can use pytest.mark.parametrize for it.

And please do the same for the other two tests below.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! pytest.mark.parametrize was great!
I've used the changes key in the pull_request event's data for both action opened and edited. It keeps the both the cases to be used from single function. I hope it wont be a problem 🙂

Comment thread tests/test_bpo.py Outdated
await bpo.router.dispatch(event, gh)
body_data = gh.patch_data
assert body_data["body"].count("[bpo-123](https://www.bugs.python.org/issue123)") == 2
assert '123456' in gh.patch_url

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use double quotes to be consistent with the rest.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really sorry for this error. I fixed this, and there was one previous occurence, so I fixed that too.
If the change for previous occurence of single quotes shouldn't have been done, I'll be happy to revert that change 🙂

Comment thread bedevere/bpo.py Outdated

def check_hyperlink(match):
"""The span checking of regex matches takes care of cases like bpo-123 [bpo-123]…"""
issue = match.group('issue')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use double quotes for your changes.
I know we haven't been consistent in the past, but since this is new code, might as well be more consistent about it. :)

@Mariatta Mariatta left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I removed a couple extra blank lines, but I think the rest looks great :)

@Mariatta Mariatta merged commit 93a67e3 into python:master Jul 27, 2018
@Mariatta

Copy link
Copy Markdown
Member

Thanks!! 🌮

Comment thread bedevere/bpo.py
if presence is False:
new_body = new_body + leftover_body[:match.start()]
leftover_body = leftover_body[match.end():]
new_body = new_body + match.expand("[bpo-\g<issue>](https://www.bugs.python.org/issue\g<issue>)")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See python/core-workflow#292. I think www. is redundant here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's not accurate.

Comment thread bedevere/bpo.py
"""Uses infinite loop for updating the string being searched dynamically."""
new_body = ""
leftover_body = body
ISSUE_RE = re.compile(r"bpo-(?P<issue>\d+)")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't word boundary anchors \b needed here?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably wouldn't hurt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Automatically hyperlink bpo- text

5 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.