Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- After a SAML login, `cloudsmith auth` saves the Workspace to `config.ini`. It writes to the `[profile:NAME]` section of the selected profile, or to `[default]` when you do not select a profile. The CLI writes to the file or directory that `--config-file` gives, or else to your user-level `config.ini`. If the `config.ini` does not exist, the CLI creates it.
- Using `#!/usr/bin/env sh` as shebang path for unix credential helpers.
- The minimum version of `cloudsmith-api` is now 2.0.42.
- The update notice and `cloudsmith update` now link to the version's entry in the Cloudsmith changelog (`https://cloudsmith.com/changelog/cli-v<major>-<minor>-<patch>`) instead of its GitHub release page.

### Deprecated

Expand Down
21 changes: 10 additions & 11 deletions cloudsmith_cli/core/installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,23 @@
#: Where a user downloads a fresh standalone build when self-update cannot run.
RELEASES_LATEST_URL = "https://github.com/cloudsmith-io/cloudsmith-cli/releases/latest"

#: Base for a version's GitHub release page. Each release is tagged ``v<version>``
#: and its page renders that version's changelog, so it answers "what do I gain
#: by upgrading?" for the exact version being offered.
_RELEASE_TAG_URL_TEMPLATE = (
"https://github.com/cloudsmith-io/cloudsmith-cli/releases/tag/v{version}"
)
#: Base for a version's changelog entry on cloudsmith.com. Each entry's slug is
#: ``cli-v<major>-<minor>-<patch>``, so it answers "what do I gain by
#: upgrading?" for the exact version being offered.
_CHANGELOG_URL_TEMPLATE = "https://cloudsmith.com/changelog/cli-v{version}"


def changelog_url(version=None):
"""Return the changelog URL for ``version`` (its release page), or the list.
"""Return the changelog URL for ``version``, or the releases listing.

With a version, points at that version's release page (tagged
``v<version>``), which shows exactly what changed. Without one, points at
the releases listing.
With a version, points at that version's changelog entry
(``cli-v<major>-<minor>-<patch>``), which shows exactly what changed.
Without one, points at the releases listing.
"""
if not version:
return RELEASES_LATEST_URL
return _RELEASE_TAG_URL_TEMPLATE.format(version=str(version).lstrip("v"))
slug = str(version).lstrip("v").replace(".", "-")
return _CHANGELOG_URL_TEMPLATE.format(version=slug)


_UPGRADE_INSTRUCTIONS = {
Expand Down
10 changes: 8 additions & 2 deletions cloudsmith_cli/core/tests/test_installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,16 @@ def test_channels_return_instruction(self, channel):

class TestChangelogUrl:
@pytest.mark.parametrize("version", ["2.0.0", "v2.0.0"])
def test_points_at_release_tag(self, version):
def test_points_at_changelog_entry(self, version):
assert (
installation.changelog_url(version)
== "https://github.com/cloudsmith-io/cloudsmith-cli/releases/tag/v2.0.0"
== "https://cloudsmith.com/changelog/cli-v2-0-0"
)

def test_multi_digit_parts(self):
assert (
installation.changelog_url("1.12.3")
== "https://cloudsmith.com/changelog/cli-v1-12-3"
)

@pytest.mark.parametrize("version", [None, ""])
Expand Down
Loading