Skip to content
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

fix(framework-core): core-library get remote patch ranges #84

Merged
merged 8 commits into from Aug 18, 2020

Conversation

TomKristie
Copy link
Contributor

In order to suggest lines to comment on in a PR, code-suggester needs to know what lines are in-scope. If a line is suggested that does not appear in the PR file hunk, GitHub throws an error. Therefore we will need know each file's patch range for the updated content.

Hence, fetch the remote pull request so that each file's updated patch range is collected: the valid patch ranges.
Some files will not have a patch field returned, usually because the file is too large: invalid files. This is a subset of the total invalid files of that PR. Collect these files as well for future use.

Towards #59

@TomKristie TomKristie requested review from chingor13 and a team August 17, 2020 20:50
@TomKristie TomKristie requested a review from a team as a code owner August 17, 2020 20:50
@codecov
Copy link

codecov bot commented Aug 17, 2020

Codecov Report

❗ No coverage uploaded for pull request base (comment-pr@1531c8b). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@              Coverage Diff              @@
##             comment-pr      #84   +/-   ##
=============================================
  Coverage              ?   88.50%           
=============================================
  Files                 ?       16           
  Lines                 ?     1522           
  Branches              ?      115           
=============================================
  Hits                  ?     1347           
  Misses                ?      174           
  Partials              ?        1           

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 1531c8b...8164181. Read the comment docs.

test/remote-github-patch-text.ts Outdated Show resolved Hide resolved
test/remote-github-patch-text.ts Show resolved Hide resolved
test/remote-github-patch-text.ts Outdated Show resolved Hide resolved
test/remote-github-patch-text.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@bcoe bcoe left a comment

Choose a reason for hiding this comment

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

Just a drive by read of this code, I think this work is looking really solid 👍

});
});

describe('Extracting multiple GitHub files ranges from patch text', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I appreciate how well tested this work is 👌

Copy link
Contributor

@chingor13 chingor13 left a comment

Choose a reason for hiding this comment

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

nit on variable naming, otherwise LGTM

test/remote-github-patch-text.ts Outdated Show resolved Hide resolved
});
it('Returns a single range file record when there is a single 1 line patch hunk', () => {
const firstLinePatch = '@@ -1 +1 @@\n-Hello foo\n+';
const singlelineFIleName = 'single-line-patch.txt';
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: weird casing

@TomKristie TomKristie merged commit 29f5136 into googleapis:comment-pr Aug 18, 2020
@TomKristie TomKristie deleted the valid-comment-ranges branch August 18, 2020 20:34
chingor13 added a commit that referenced this pull request Sep 25, 2020
…n pull requests (#105)

* feat(patch text to hunk bounds): support regex for patch texts (#83)

* fix(patch text to hunk bounds): support regex for patch texts

* more comments and more tests

* fix(framework-core): core-library get remote patch ranges (#84)

* fix(framework-core): given files old content and new content, compute the valid hunks (#86)

* fix(framework-core): parse raw changes to ranges

* refactor(framework-core): rename modules, functions, & re-org project structure (#89)

* fix(framework-core): hunk to patch object (#91)

* feat: build failure message from invalid hunks (#90)

* test: add failing stub and test for building the failure message

* fix: implement message building

* fix: use original line numbers in error message

* docs: add docstring

* docs: add note about empty input returning empty string

* feat(framework-core): comment on prs given suggestions (#93)

* feat(framework-core): main interface for create review on a pull request (#114)

* feat(framework-core): main interface for create review on a pull request

* docs: fix typo

* nits and typos...

* gts lint warning fix

* fix(framework-core): combine review comments (#116)

* fix(framework-core): collapsing timeline and inline comments into single review

* test: fixed imports

* added case when there are out of scope suggestions and no valid suggestions

* feat(framework-core): return review number and variable renaming (#117)

* feat(framework-core): return review number and variable renaming

* lint

Co-authored-by: Jeff Ching <chingor@google.com>
Co-authored-by: Justin Beckwith <justin.beckwith@gmail.com>
Co-authored-by: Benjamin E. Coe <bencoe@google.com>
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.

None yet

3 participants