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

Add support for short repository property and make it default #83

Merged
merged 1 commit into from
Sep 19, 2016
Merged

Add support for short repository property and make it default #83

merged 1 commit into from
Sep 19, 2016

Conversation

zlatanvasovic
Copy link
Contributor

As requested in bevry/editions#16. Please review this to make sure there are no issues. About the README changes, I just ran the compile script (npm run-script compile).

/cc @balupton

const githubMatch = (this.mergedPackageData.repository.url || this.mergedPackageData.homepage).match(/github\.com\/(.+?)(?:\.git|\/)?$/)
let repo = this.mergedPackageData.repository || null
const githubMatch = (this.mergedPackageData.repository.url || this.mergedPackageData.homepage).match(/github\.com\/(.+?)(?:\.git|\/)?$/) ||
(this.mergedPackageData.repository.match(/^(.+\/.+)$/) && !this.mergedPackageData.repository.match(/^(.+:.+\/.+)$/))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Couldn't do this the other way. If you have a better idea how to match user/repo but not (bitbucket|gist|gitlab):user/repo, please tell me.

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 do it:

const githubMatch = this.mergedPackageData.repository.match(/^(?:github:)?(.+\/.+)$/)
  || (this.mergedPackageData.repository.url || this.mergedPackageData.homepage).match(/github\.com\/(.+?)(?:\.git|\/)?$/

The ?: means non capturing group, so whatever is in the ?: group doesn't affect the match.

Copy link
Contributor Author

@zlatanvasovic zlatanvasovic Sep 19, 2016

Choose a reason for hiding this comment

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

It looks like that doesn't work. Basically, all it has to do is to ignore repository names which contain : (e.g. bitbucket:user/repo). I've checked it, creating GitHub reposities with : in it is impossible, they're automatically converted to -, so the : check should work fine for the purpose.

Copy link
Member

Choose a reason for hiding this comment

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

Okay, I'll clone and take a look 👍

Copy link
Member

@balupton balupton Sep 19, 2016

Choose a reason for hiding this comment

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

        const githubMatch = this.mergedPackageData.repository.match(/^(?:github:)?([^\/]+\/[^\/]+)$/) ||
            (this.mergedPackageData.repository.url || this.mergedPackageData.homepage).match(/github\.com\/(.+?)(?:\.git|\/)?$/)

Seems to do the trick. Can you verify?

Copy link
Member

Choose a reason for hiding this comment

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

Actually, I think I understand what you mean now. Leave it with me. Will merge it in and adjust.

Copy link
Member

@balupton balupton left a comment

Choose a reason for hiding this comment

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

Two changes to be made. I'll give you a few days to make them, otherwise I'll jump on it 👍

const githubMatch = (this.mergedPackageData.repository.url || this.mergedPackageData.homepage).match(/github\.com\/(.+?)(?:\.git|\/)?$/)
let repo = this.mergedPackageData.repository || null
const githubMatch = (this.mergedPackageData.repository.url || this.mergedPackageData.homepage).match(/github\.com\/(.+?)(?:\.git|\/)?$/) ||
(this.mergedPackageData.repository.match(/^(.+\/.+)$/) && !this.mergedPackageData.repository.match(/^(.+:.+\/.+)$/))
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 do it:

const githubMatch = this.mergedPackageData.repository.match(/^(?:github:)?(.+\/.+)$/)
  || (this.mergedPackageData.repository.url || this.mergedPackageData.homepage).match(/github\.com\/(.+?)(?:\.git|\/)?$/

The ?: means non capturing group, so whatever is in the ?: group doesn't affect the match.

type: 'git',
url: `https://github.com/${githubSlug}.git`
},
repository: `${githubSlug}`,
Copy link
Member

Choose a reason for hiding this comment

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

repository: githubSlug, is fine here

@balupton balupton merged commit 1e6922c into bevry:master Sep 19, 2016
balupton added a commit that referenced this pull request Sep 19, 2016
balupton added a commit that referenced this pull request Sep 19, 2016
@balupton
Copy link
Member

Released to v1.2.0 👏

@zlatanvasovic zlatanvasovic deleted the repository branch September 19, 2016 20:06
@balupton
Copy link
Member

balupton commented Sep 19, 2016

My only concern with this is if older versions of npm doesn't support this, however I would assume it is not important for npm and node at all, so I'm not fussed as would be a non-issue

@zlatanvasovic
Copy link
Contributor Author

I remember using this a few years ago, back in the time of node 0.x. I guess it isn't a problem for older versions.

@balupton
Copy link
Member

Even better!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement or suggestion
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants