Skip to content

Conversation

@probablycorey
Copy link
Contributor

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 --version flag that Cobra uses. To get around this and have gh version and gh --version use the same string I used the SetVersionTemplate method https://github.com/spf13/cobra#version-flag

Closes #111

img

@probablycorey probablycorey self-assigned this Jan 13, 2020
Copy link
Contributor

@mislav mislav left a 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+$`)
Copy link
Contributor

@mislav mislav Jan 13, 2020

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.

Copy link
Contributor Author

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)
Copy link
Contributor

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?

Copy link
Contributor Author

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?

@vilmibm vilmibm merged commit f3b3888 into master Jan 14, 2020
@mislav mislav deleted the release-the-kraken branch January 22, 2020 23:00
mislav pushed a commit that referenced this pull request Jan 23, 2020
Add changelog link to `gh version` and `gh --version`
Stonre pushed a commit to Stonre/strands-fork that referenced this pull request Jul 21, 2025
- 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI changelog

4 participants