From ece91a5c3b37a6aaf6077060af98b7274af2ae92 Mon Sep 17 00:00:00 2001 From: Rafael Xavier de Souza Date: Wed, 5 Jun 2013 10:39:07 -0300 Subject: [PATCH] Release: Handle prevVersion when minor or patch are 0 (zero) --- build/release/release.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/build/release/release.js b/build/release/release.js index df94b1c08..32f832acd 100644 --- a/build/release/release.js +++ b/build/release/release.js @@ -105,8 +105,7 @@ function getVersions() { if ( preRelease ) { newVersion = preRelease; - // Note: prevVersion is not currently used for pre-releases. The TODO - // below about 1.10.0 applies here as well. + // Note: prevVersion is not currently used for pre-releases. prevVersion = nextVersion = currentVersion; } else { newVersion = currentVersion.substr( 0, currentVersion.length - 3 ); @@ -115,15 +114,14 @@ function getVersions() { minor = parseInt( parts[ 1 ], 10 ); patch = parseInt( parts[ 2 ], 10 ); - // TODO: handle 1.10.0 - // Also see comment above about pre-releases - if ( patch === 0 ) { - abort( "This script is not smart enough to handle the 1.10.0 release." ); + if ( minor === 0 && patch === 0 ) { + abort( "This script is not smart enough to handle major release (eg. 2.0.0)." ); + } else if ( patch === 0 ) { + prevVersion = git( "for-each-ref --count=1 --sort=-authordate --format='%(refname:short)' refs/tags/" + [ major, minor - 1 ].join( "." ) + "*" ).trim(); + } else { + prevVersion = [ major, minor, patch - 1 ].join( "." ); } - prevVersion = patch === 0 ? - [ major, minor - 1, 0 ].join( "." ) : - [ major, minor, patch - 1 ].join( "." ); nextVersion = [ major, minor, patch + 1 ].join( "." ) + "pre"; } -- 2.39.5