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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add addFilesByExtension method & allow leading slash in path #694

Merged
merged 4 commits into from Jan 11, 2021

Conversation

phated
Copy link
Contributor

@phated phated commented Jan 11, 2021

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #692 Fixes #693 馃

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

codecov bot commented Jan 11, 2021

Codecov Report

Merging #694 (b22923f) into master (9f69f41) will increase coverage by 0.06%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #694      +/-   ##
==========================================
+ Coverage   85.38%   85.44%   +0.06%     
==========================================
  Files          49       49              
  Lines        5945     5972      +27     
  Branches      531      565      +34     
==========================================
+ Hits         5076     5103      +27     
  Misses        868      868              
  Partials        1        1              
Impacted Files Coverage 螖
src/github.ts 83.69% <100.00%> (+0.42%) 猬嗭笍
src/release-pr.ts 90.08% <100.00%> (酶)

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 9f69f41...b22923f. Read the comment docs.

@phated phated changed the title New addFilesByExtension method & leading slash in path fix feat: add addFilesByExtension method & allow leading slash in path Jan 11, 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.

Only real nit, is that we should be consistent about removing the leading \.

I'm fine with not abstracting the removing of a leading slash into a helper yet.


Disclaimer I always give folks using the search based API, GitHub sometimes doesn't immediately index all files. The approach works, but I think can have some hiccups when a new file is initially added (they eventually correct themselves.)

@@ -329,7 +329,11 @@ export class ReleasePR {

static addPathStatic(file: string, path?: string) {
if (path === undefined) {
return file;
if (file.startsWith('/')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it make sense to also check for \?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure! I was originally getting these back from the github API, which always returns /, but I could see someone trying to do a path normalization on windows.

src/github.ts Outdated
): Promise<string[]> {
let q = `extension:${extension}+repo:${this.owner}/${this.repo}`;
if (prefix) {
prefix = prefix.replace(/[/\\]$/, '');
Copy link
Contributor

Choose a reason for hiding this comment

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

IF we find ourselves doing this too many more times, it might be worth pulling into a helper, removeLeadingSlash?

Could just be in the github.js class I suppose.

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.

Awesome, thanks for the contribution 馃帀

@bcoe bcoe merged commit 0d63813 into googleapis:master Jan 11, 2021
@phated phated deleted the phated/util-fixes branch January 11, 2021 01:58
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
2 participants