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

Refactor GitHub Code Search, and provide a non-repository scoped version [githubcodesearch] #10687

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ccoVeille
Copy link

@ccoVeille ccoVeille commented Nov 21, 2024

Fixes #10686

Copy link
Contributor

github-actions bot commented Nov 21, 2024

Messages
📖 ✨ Thanks for your contribution to Shields, @ccoVeille!

Generated by 🚫 dangerJS against 0cf4a48

@ccoVeille ccoVeille marked this pull request as ready for review November 21, 2024 22:27
@ccoVeille
Copy link
Author

It's ready for review. Thanks

@jNullj jNullj added the service-badge New or updated service badge label Nov 22, 2024
@jNullj jNullj changed the title Refactor GitHub Code Search, and provide a non-repository scoped version Refactor GitHub Code Search, and provide a non-repository scoped version [githubsearch] Nov 22, 2024
@jNullj jNullj changed the title Refactor GitHub Code Search, and provide a non-repository scoped version [githubsearch] Refactor GitHub Code Search, and provide a non-repository scoped version [githubcodesearch githubrepocodesearch] Nov 22, 2024
@jNullj jNullj changed the title Refactor GitHub Code Search, and provide a non-repository scoped version [githubcodesearch githubrepocodesearch] Refactor GitHub Code Search, and provide a non-repository scoped version [githubcodesearch] Nov 22, 2024
Copy link
Contributor

@jNullj jNullj left a comment

Choose a reason for hiding this comment

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

Thank you for adding these changes, i have some feedback and would love if you could make some changes

},
}

async handle({ user, repo, query }) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We can remove these as they are unused

Suggested change
async handle({ user, repo, query }) {
async handle({ query }) {

Comment on lines +34 to +37
static route = {
base: 'github/search',
pattern: ':query+',
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This will not work with the route of GitHubRepoCodeSearch as this includes all paths of the GitHubRepoCodeSearch in it.
If you make a request to http://localhost/github/search/torvalds/linux/goto it calls GitHubCodeSearch and not GitHubRepoCodeSearch.

Please change the route

Copy link
Member

Choose a reason for hiding this comment

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

Good catch on this issue.

In terms of how to solve it..

There's no way to distinguish between /:user/:repo/:query+ and a /:query+ that contains multiple slash characters.

One way round this would be to put the non repo-scoped version on a different route (so we pick /github/global-search/:query+ or something?). However, I think the optimal way to solve this would be to match what we've done with the GitHub Issue Search badge and make query a QueryString param instead of a path param.

https://shields.io/badges/git-hub-issue-custom-search
https://shields.io/badges/git-hub-issue-custom-search-in-repo

That way they could be /github/search?query=foo and /github/search/user/repo?query=foo, and query can contain any number of slashes. It would also make the URL format match up with this existing conceptually similar badge.

In order to do this, we'd also have to add a redirector for /github/search/:user/:repo/:query+ which converts query to a QueryString param to avoid breaking existing badges. There is an example of how to do this at https://github.com/badges/shields/blob/master/services/gitlab/gitlab-coverage-redirect.service.js - this redirect switches branch to a query param.

Copy link
Author

Choose a reason for hiding this comment

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

Thank you for your actionable feedbacks. I'll take a look.

Stay tuned

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
service-badge New or updated service badge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

extends GitHub Code Search
3 participants