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

feat: add add GitHub helpers for findFilesByFilenameAndRef and findFilesByExtensionAndRef #712

Merged
merged 6 commits into from
Jan 22, 2021

Conversation

chingor13
Copy link
Contributor

@chingor13 chingor13 commented Jan 21, 2021

Fixes #656 - using the git tree API should be instantaneous and not reliant on the search API.

Fixes #710 - provides extra helpers for finding files by filename/extension within a branch.

Refactors findFiles to use the tree API for listing files.

@chingor13 chingor13 requested a review from a team as a code owner January 21, 2021 21:07
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Jan 21, 2021
@codecov
Copy link

codecov bot commented Jan 21, 2021

Codecov Report

Merging #712 (133fe76) into master (9ae5620) will increase coverage by 0.18%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #712      +/-   ##
==========================================
+ Coverage   86.78%   86.96%   +0.18%     
==========================================
  Files          55       55              
  Lines        6582     6673      +91     
  Branches      586      594       +8     
==========================================
+ Hits         5712     5803      +91     
  Misses        869      869              
  Partials        1        1              
Impacted Files Coverage Δ
src/github.ts 84.97% <100.00%> (+1.27%) ⬆️

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 9ae5620...133fe76. Read the comment docs.

@chingor13 chingor13 requested a review from bcoe January 21, 2021 21:37
@chingor13 chingor13 changed the title refactor: use tree API for finding files by name or extension feat: add add GitHub helpers for findFilesByFilenameAndRef and findFilesByExtensionAndRef Jan 21, 2021
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.

The comment re: using sinon for mocking doesn't need to be a blocker, but I wonder if it makes the codebase more maintainable long term.

I've found people really wrestle with nock, and it might be better to only use it for select things, where we want to be darn sure we've exercised code paths that rely on it.

let path = file.path!;
// strip the prefix if provided
if (prefix) {
const pfix = new RegExp(`^${prefix}[/\\\\]`);
Copy link
Contributor

Choose a reason for hiding this comment

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

this is elegant, I like the approach.

extension: string,
ref: string,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should ref be optional, based on the description of the method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I originally had it optional as an overload of fileFilesByExtension(extension, prefix?, ref?), but then opted to make it a separate explicit method. I'll fix the docs to not make it optional.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

const graphql = JSON.parse(
readFileSync(resolve(fixturesPath, 'commits-yoshi-java.json'), 'utf8')
);
const req = nock('https://api.github.com')
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if it would be worth moving some of this logic to sinon, like here I've been finding that it feels a bit more maintainable than enumerating all of the GitHub endpoints we'll be interacting with.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like this a lot. Let me do it in a separate, follow-up PR to avoid muddying up this PR.

@bcoe bcoe merged commit 0258bd6 into googleapis:master Jan 22, 2021
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

File search only considers the default branch Fail to update pom file versions when proposing release PR
2 participants