-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* link to changelog in version * link to specific changelog version number * update CHANGELOG headings to match expected format * clean up and add tests * handle errors * use https * update test url
- Loading branch information
Showing
4 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { helper } from '@ember/component/helper'; | ||
|
||
/* | ||
This helper returns a url to the changelog for the specified version. | ||
It assumes that Changelog headers for Vault versions >= 1.4.3 are structured as: | ||
## v1.5.0 | ||
### Month, DD, YYYY | ||
## v1.4.5 | ||
### Month, DD, YYY | ||
etc. | ||
*/ | ||
|
||
export function changelogUrlFor([version]) { | ||
let url = 'https://www.github.com/hashicorp/vault/blob/master/CHANGELOG.md#'; | ||
|
||
try { | ||
// strip the '+prem' from enterprise versions and remove periods | ||
let versionNumber = version | ||
.split('+')[0] | ||
.split('.') | ||
.join(''); | ||
|
||
// only recent versions have a predictable url | ||
if (versionNumber >= '143') { | ||
return url.concat('v', versionNumber); | ||
} | ||
} catch (e) { | ||
console.log(e); | ||
console.log('Cannot generate URL for version: ', version); | ||
} | ||
return url; | ||
} | ||
|
||
export default helper(changelogUrlFor); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default, changelogUrlFor } from 'core/helpers/changelog-url-for'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupRenderingTest } from 'ember-qunit'; | ||
import { changelogUrlFor } from '../../../helpers/changelog-url-for'; | ||
|
||
const CHANGELOG_URL = 'https://www.github.com/hashicorp/vault/blob/master/CHANGELOG.md#'; | ||
|
||
module('Integration | Helper | changelog-url-for', function(hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
test('it builds an enterprise URL', function(assert) { | ||
const result = changelogUrlFor(['1.5.0+prem']); | ||
assert.equal(result, CHANGELOG_URL.concat('v150')); | ||
}); | ||
|
||
test('it builds an OSS URL', function(assert) { | ||
const result = changelogUrlFor(['1.4.3']); | ||
assert.equal(result, CHANGELOG_URL.concat('v143')); | ||
}); | ||
|
||
test('it returns the base changelog URL if the version is less than 1.4.3', function(assert) { | ||
const result = changelogUrlFor(['1.4.0']); | ||
assert.equal(result, CHANGELOG_URL); | ||
}); | ||
|
||
test('it returns the base changelog URL if version cannot be found', function(assert) { | ||
const result = changelogUrlFor(['']); | ||
assert.equal(result, CHANGELOG_URL); | ||
}); | ||
}); |