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

Allow [GitHub] tag badge to sort by date #2157

Merged
merged 5 commits into from
Oct 8, 2018
Merged

Conversation

chris48s
Copy link
Member

@chris48s chris48s commented Oct 7, 2018

Following on from #2117 (comment)

  • I've modified the /release badge so we can use /release-pre and changed the home pages example. The legacy /all suffix will still work (for backwards-compatibility) but its not documented.
  • I haven't changed anything else on /release. Looking into it, we're using the prerelease key there rather than assuming semver so we don't have the same issue there that we do with tags.
  • I've added a tag-date endpoint. I changed my mind and decided not to go with sort=semver/sort=date for 2 reasons:
    • It allows /tag-pre/username/repo.svg?sort=date which is a bit odd/unclear
    • We don't really have a good way to get the querystring in BaseJsonService. This is going to be a problem with a few other services which we need to deal with when we port them, but on reflection I'd prefer not make this problem bigger.

This PR won't change the behaviour for anyone already using these badges but improves consistency and provides a way for projects that don't use SemVer (for whatever reason) to use the /tag badge with sensible expected behaviour.

Does this seem reasonable?

@chris48s chris48s added the service-badge Accepted and actionable changes, features, and bugs label Oct 7, 2018
@shields-ci
Copy link

Messages
📖

✨ Thanks for your contribution to Shields, @chris48s!

📖

Thanks for contributing to our documentation. We ❤️ our documentarians!

Generated by 🚫 dangerJS

@chris48s
Copy link
Member Author

chris48s commented Oct 7, 2018

side issue: one of the tests was failing because the GH API now returns spdx_id: "NOASSERTION" when it can't identify the licence (at least in some cases), so I've fixed that while I'm here..

RedSparr0w
RedSparr0w previously approved these changes Oct 7, 2018
Copy link
Member

@RedSparr0w RedSparr0w left a comment

Choose a reason for hiding this comment

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

👍 Changes look great to me.
Just left a minor note in regards to the regex, although this is fine to merge with whichever option you decide. 😄

@@ -15,9 +15,10 @@ const {
module.exports = class GithubTag extends LegacyService {
static registerLegacyRouteHandler({ camp, cache, githubApiProvider }) {
camp.route(
/^\/github\/tag(-?pre)?\/([^/]+)\/([^/]+)\.(svg|png|gif|jpg|json)$/,
/^\/github\/(tag-?pre|tag-date|tag)\/([^/]+)\/([^/]+)\.(svg|png|gif|jpg|json)$/,
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 think it would be better to make the - required for tag-pre?

-/^\/github\/(tag-?pre|tag-date|tag)\/([^/]+)\/([^/]+)\.(svg|png|gif|jpg|json)$/
+/^\/github\/(tag-pre|tag-date|tag)\/([^/]+)\/([^/]+)\.(svg|png|gif|jpg|json)$/

or an alternative:

/^\/github\/tag(?:-(pre|date))?\/([^/]+)\/([^/]+)\.(svg|png|gif|jpg|json)$/ (- required)
/^\/github\/tag(?:-?(pre|date))?\/([^/]+)\/([^/]+)\.(svg|png|gif|jpg|json)$/ (- optional)

Copy link
Member Author

Choose a reason for hiding this comment

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

I was keeping this to avoid making a breaking change:

/^\/github\/tag(-?pre)?\/([^/]+)\/([^/]+)\.(svg|png|gif|jpg|json)$/,

..but now you mention it, one of the issues here was we've never put an example of this on the home page so I doubt there is much usage in the wild. It was only added quite recently. Lets change it now 👍

Copy link
Member

Choose a reason for hiding this comment

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

Ah yes, Good point!

@@ -13,13 +13,13 @@ const {
module.exports = class GithubRelease extends LegacyService {
static registerLegacyRouteHandler({ camp, cache, githubApiProvider }) {
camp.route(
/^\/github\/release\/([^/]+\/[^/]+)(?:\/(all))?\.(svg|png|gif|jpg|json)$/,
/^\/github\/release(-?pre)?\/([^/]+\/[^/]+)(?:\/(all))?\.(svg|png|gif|jpg|json)$/,
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 think it would be better to make the - required for tag-pre?

-/^\/github\/release(-?pre)?\/([^/]+\/[^/]+)(?:\/(all))?\.(svg|png|gif|jpg|json)$/,
+/^\/github\/release(-pre)?\/([^/]+\/[^/]+)(?:\/(all))?\.(svg|png|gif|jpg|json)$/,

@chris48s chris48s merged commit a74db34 into badges:master Oct 8, 2018
@shields-deployment
Copy link

This pull request was merged to master branch. This change is now waiting for deployment, which will usually happen within a few days. Stay tuned by joining our #ops channel on Discord!

After deployment, changes are copied to gh-pages branch:

@paulmelnikow
Copy link
Member

Catching up on some reading!

We don't really have a good way to get the querystring in BaseJsonService. This is going to be a problem with a few other services which we need to deal with when we port them, but on reflection I'd prefer not make this problem bigger.

Could you clarify what you mean? I added some query param support in #1589. The handling of examples isn't completely correct as we've seen, and it's not stripping the default parameters, though the core of the query params are working in the the (new-style) NPM badges.

@chris48s
Copy link
Member Author

chris48s commented Nov 1, 2018

Sorry - turns out I'm mistaken on this. I hadn't seen an example where we've used the queryParams arg to handle() before, but its good to know its there. That's one less thing to worry about :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
service-badge Accepted and actionable changes, features, and bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants