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: undefined response from get-github-info call #510

Merged
merged 3 commits into from
Jan 13, 2021

Conversation

tuanddd
Copy link
Contributor

@tuanddd tuanddd commented Jan 8, 2021

Fixes #509

@atlassian-cla-bot
Copy link

atlassian-cla-bot bot commented Jan 8, 2021

Hooray! All contributors have signed the CLA.

@changeset-bot
Copy link

changeset-bot bot commented Jan 8, 2021

🦋 Changeset detected

Latest commit: 9f123e0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@changesets/changelog-github Patch
@changesets/get-github-info Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@@ -2,6 +2,8 @@
import fetch from "node-fetch";
import DataLoader from "dataloader";

const validRepoNameRegex = /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/m;
Copy link
Member

Choose a reason for hiding this comment

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

Do you have any source which described what repo names are considered as valid by GitHub? Are dots allowed? Why m modifier has been used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Regex was taken from this answer on SO

And yes a little oversight on my end, the m flag is redundant, will remove it, thanks for catching that 👍

@@ -2,6 +2,8 @@
import fetch from "node-fetch";
import DataLoader from "dataloader";

const validRepoNameRegex = /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/m;
Copy link
Member

Choose a reason for hiding this comment

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

This should be the equivalent

Suggested change
const validRepoNameRegex = /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/m;
const validRepoNameRegex = /^[\w.-]+\/[\w.-]+$/;

Choose a reason for hiding this comment

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

why don't we support @ ? like '@ant-design/xxx'

@@ -121,7 +123,7 @@ export async function getInfo(
throw new Error("Please pass a commit SHA to getInfo");
}

if (!request.repo) {
if (!request.repo || !validRepoNameRegex.test(request.repo)) {
Copy link
Member

Choose a reason for hiding this comment

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

could you move the second check to a separate if and throw an error that would contain validRepoNameRegex.source? That way users should be able to get a little bit more information as to why the validation has failed

- Correct the repo regex
- Move the validation to a separate if statement to provide more
  detailed message
@tuanddd
Copy link
Contributor Author

tuanddd commented Jan 9, 2021

@Andarist I've pushed the changes 🙂

@tuanddd
Copy link
Contributor Author

tuanddd commented Jan 13, 2021

@Andarist What is blocking this?

@Andarist Andarist merged commit 3436c53 into changesets:master Jan 13, 2021
@Andarist
Copy link
Member

@Andarist What is blocking this?

My life :P

@github-actions github-actions bot mentioned this pull request Jan 13, 2021
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.

undefined result on get-github-info call
3 participants