Skip to content

Commit ece91a5

Browse files
committed
Release: Handle prevVersion when minor or patch are 0 (zero)
1 parent a52421b commit ece91a5

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

build/release/release.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@ function getVersions() {
105105

106106
if ( preRelease ) {
107107
newVersion = preRelease;
108-
// Note: prevVersion is not currently used for pre-releases. The TODO
109-
// below about 1.10.0 applies here as well.
108+
// Note: prevVersion is not currently used for pre-releases.
110109
prevVersion = nextVersion = currentVersion;
111110
} else {
112111
newVersion = currentVersion.substr( 0, currentVersion.length - 3 );
@@ -115,15 +114,14 @@ function getVersions() {
115114
minor = parseInt( parts[ 1 ], 10 );
116115
patch = parseInt( parts[ 2 ], 10 );
117116

118-
// TODO: handle 1.10.0
119-
// Also see comment above about pre-releases
120-
if ( patch === 0 ) {
121-
abort( "This script is not smart enough to handle the 1.10.0 release." );
117+
if ( minor === 0 && patch === 0 ) {
118+
abort( "This script is not smart enough to handle major release (eg. 2.0.0)." );
119+
} else if ( patch === 0 ) {
120+
prevVersion = git( "for-each-ref --count=1 --sort=-authordate --format='%(refname:short)' refs/tags/" + [ major, minor - 1 ].join( "." ) + "*" ).trim();
121+
} else {
122+
prevVersion = [ major, minor, patch - 1 ].join( "." );
122123
}
123124

124-
prevVersion = patch === 0 ?
125-
[ major, minor - 1, 0 ].join( "." ) :
126-
[ major, minor, patch - 1 ].join( "." );
127125
nextVersion = [ major, minor, patch + 1 ].join( "." ) + "pre";
128126
}
129127

0 commit comments

Comments
 (0)