Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 9e4d42c

Browse files
chore(version-info): use branchPattern to check tag
We have two fields in package.json for checking the current version: * branchVersion * branchPattern The `branchVersion` field is used to work out what version to use in the docs application, so we should not update this to the most recent version until that version is on the Google CDN. Otherwise the docs app will break. The `branchPattern` is used to determine what branch we are currently working from and is generally used as a gate-keeper to prevent invalid releases from the wrong branch. The `getTaggedVersion()` method was using the `branchVersion` to check that the tagged commit was valid but this fails when we are moving to a new minor version with release candidates. This fix avoids the problem by doing a custom comparison against the `branchPattern` instead.
1 parent ad3a1f9 commit 9e4d42c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/versions/version-info.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ function getBuild() {
7373
return 'sha.' + hash;
7474
}
7575

76+
function checkBranchPattern(version, branchPattern) {
77+
// check that the version starts with the branch pattern minus its asterisk
78+
// e.g. branchPattern = '1.6.*'; version = '1.6.0-rc.0' => '1.6.' === '1.6.'
79+
return version.slice(0, branchPattern.length - 1) === branchPattern.replace('*', '');
80+
}
7681

7782
/**
7883
* If the current commit is tagged as a version get that version
@@ -85,7 +90,7 @@ var getTaggedVersion = function() {
8590
var tag = gitTagResult.output.trim();
8691
var version = semver.parse(tag);
8792

88-
if (version && semver.satisfies(version, currentPackage.branchVersion)) {
93+
if (version && checkBranchPattern(version, currentPackage.branchPattern)) {
8994
version.codeName = getCodeName(tag);
9095
version.full = version.version;
9196
version.branch = 'v' + currentPackage.branchPattern.replace('*', 'x');

0 commit comments

Comments
 (0)