-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
[Depfu] Add support for Gitlab #7475
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Think we could use another test but otherwise LGTM
@chris48s maybe not worth discussing as part of this PR since the route change is both consistent with what we had before as well as other dependency management/update services, but it seems like this class of badge routes are all missing the NOUN portion from our canonical badge url pattern
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. Thanks for having a look at this and providing tests.
services/depfu/depfu.service.js
Outdated
static route = { base: 'depfu', pattern: ':user/:repo' } | ||
static route = { | ||
base: 'depfu', | ||
pattern: ':vcsType(github|gitlab)/:user/:repo', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With GitLab we can't just use :user/:repo
, repos can be nested in an aribtrary number of nested subgroups e.g:
https://gitlab.com/megabyte-labs/docker/ci-pipeline/ansible-lint so for projects that work with gitlab we would usually make the route something like :vcsType(github|gitlab)/:project+
(which allows an arbitrary number of slashes) and then call https://depfu.com/${vcsType}/shields/${project}
assuming depfu inherits that design descension and exposes it in the same way. Do we have an example of this?
@calebcartwright I think if we want to change it to |
I just created an example project to test this. It might be a bit trickier, because Depfu seems to require urlencoded subgroup separators: https://depfu.com/gitlab/shields/shields-example-group%252Fsubgroup/example-nodejs (replacing I guess the best approach would be to parse the |
Lets use For the Gitlab case we can do something like encodeURIComponent(project.substr(0, project.lastIndexOf('/')))
project.substr(project.lastIndexOf('/')) We'll also want to make sure project has at least one / in it before doing that, so something like if (!project.includes('/')) {
throw InvalidParameter()
} shields/core/base-service/errors.js Line 157 in 23c0406
For the Github case, we can just pass project as-is |
I updated this PR according to the review comments:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great - thanks for finishing this up 👍 Sorry it took a few days to get back to it
Fixes #7474
Following the recommendation #7474 (comment) of @chris48s, this PR adds a
:vcsType
parameter to depfu URLs to select between Github and Gitlab. Badges without a VCS type are redirected to the Github route via a legacy route.