0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Added link to GitHub commit if prerelease version

refs https://ghost.slack.com/archives/C025584CA/p1678886661494989?thread_ts=1678886465.260379&cid=C025584CA

- if we're running a prerelease, our usual format is `<major>.<minor>.<patch>-pre.<commit hash>.<build>`
- if you wanna see what commit it was built on, you have to copy and
  paste the hash into a GitHub URL
- this provides an easier route to the commit by detecting if the
  version is our special format and links direct to GitHub if so
This commit is contained in:
Daniel Lockyer 2023-03-15 14:45:01 +01:00
parent a5ac2bd470
commit 7409f9524a
No known key found for this signature in database
2 changed files with 22 additions and 4 deletions

View file

@ -19,7 +19,7 @@
<section class="gh-env-details gh-about-box grey">
<ul class="gh-env-list">
{{#if this.linkToGitHubReleases}}
<li><strong>Version:</strong> <a href="https://github.com/TryGhost/Ghost/releases/tag/v{{this.config.version}}" target="_blank" rel="noopener noreferrer">{{this.config.version}}</a></li>
<li><strong>Version:</strong> <a href="{{this.linkToGitHubReleases}}" target="_blank" rel="noopener noreferrer">{{this.config.version}}</a></li>
{{else}}
<li><strong>Version:</strong> {{this.config.version}}</li>
{{/if}}

View file

@ -1,5 +1,6 @@
import Component from '@glimmer/component';
import config from 'ghost-admin/config/environment';
import semver from 'semver';
import {inject} from 'ghost-admin/decorators/inject';
import {inject as service} from '@ember/service';
@ -21,9 +22,26 @@ export default class AboutModal extends Component {
}
get linkToGitHubReleases() {
// Don't link to GitHub Releases if the version contains the
// pre-release identifier
return !this.config.version.includes('-pre.');
if (this.config.version.includes('-pre.')) {
try {
const semverVersion = semver.parse(this.config.version, {includePrerelease: true});
// Ensure this follows our prerelease format
if (semverVersion
&& semverVersion.prerelease?.[0] === 'pre'
&& semverVersion.prerelease?.[1]
&& Number.isInteger(semverVersion.prerelease?.[2])
) {
return `https://github.com/TryGhost/Ghost/commit/${semverVersion.prerelease[1]}`;
}
return false;
} catch (e) {
return false;
}
}
return `https://github.com/TryGhost/Ghost/releases/tag/v${this.config.version}`;
}
get showSystemInfo() {