-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Add changelog link to gh version and gh --version
#221
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
Conversation
mislav
left a comment
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, simple implementation!
|
|
||
| func changelogURL(version string) string { | ||
| path := "https://github.com/github/homebrew-gh" | ||
| r := regexp.MustCompile(`^v\d+\.\d+.\d+$`) |
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.
Is this mechanism designed to avoid matching prereleases, e.g. v1.2.3-pre.5, or could we consider supporting them? Since we already use them.
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.
It was mostly to avoid our dev release version numbers like 0.3.5-97-g4f97cda. I can make it work with pre-releases too.
| path := "https://github.com/github/homebrew-gh" | ||
| r := regexp.MustCompile(`^v\d+\.\d+.\d+$`) | ||
| if !r.MatchString(version) { | ||
| return fmt.Sprintf("%s/releases/latest", path) |
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.
I'm not sure about this fallback to /releases/latest— if the point of this feature is to link users to release notes that are directly applicable to their version of CLI, wouldn't linking to /latest break that promise, since the user's currently installed CLI version might not be the latest stable release?
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.
Maybe not showing any url makes more sense in that case?
Add changelog link to `gh version` and `gh --version`
- Add a single script that runs the commands we want contributions to run.
- Revamp the contribution template by:
- Using HTML comments to guide the author, reducing the need to delete the text
- Converting the type of change to be a flat list, allowing authors to delete all except the one they want
- Updated the checklist items to allow items that are unnecessary to still be checked
Co-authored-by: Mackenzie Zastrow <[email protected]>
This was pretty straight forward. If the version matches the vX.X.X pattern it will give a link to that tag. If it doesn't the url will link to the latest changelog.
One thing that was a little tricky was getting it to work with the build-in
--versionflag that Cobra uses. To get around this and havegh versionandgh --versionuse the same string I used theSetVersionTemplatemethod https://github.com/spf13/cobra#version-flagCloses #111