Implement version major.minor.release-stage.build (#3011)

This commit is contained in:
Javier Serrano Polo
2016-09-10 02:27:59 +00:00
committed by GitHub
parent eb86e25fd8
commit 5eb0ae2d75
10 changed files with 120 additions and 75 deletions

View File

@@ -147,13 +147,13 @@ void ConfigManager::upgrade()
ProjectVersion createdWith = m_version;
if ( createdWith.setCompareType(Build) < "1.1.90" )
if ( createdWith.setCompareType(ProjectVersion::Build) < "1.1.90" )
{
upgrade_1_1_90();
}
// Don't use old themes as they break the UI (i.e. 0.4 != 1.0, etc)
if ( createdWith.setCompareType(Minor) != LMMS_VERSION )
if ( createdWith.setCompareType(ProjectVersion::Minor) != LMMS_VERSION )
{
m_artworkDir = defaultArtworkDir();
}

View File

@@ -939,15 +939,15 @@ void DataFile::upgrade()
{
upgrade_0_4_0_rc2();
}
if( version < ProjectVersion("1.0.99", CompareType::Release) )
if( version < "1.0.99-0" )
{
upgrade_1_0_99();
}
if( version < ProjectVersion("1.1.0", CompareType::Release) )
if( version < "1.1.0-0" )
{
upgrade_1_1_0();
}
if( version < ProjectVersion("1.1.91", CompareType::Release) )
if( version < "1.1.91-0" )
{
upgrade_1_1_91();
}
@@ -1018,12 +1018,13 @@ void DataFile::loadData( const QByteArray & _data, const QString & _sourceFile )
{
// compareType defaults to Build,so it doesn't have to be set here
ProjectVersion createdWith = root.attribute( "creatorversion" );
ProjectVersion openedWith = LMMS_VERSION;;
ProjectVersion openedWith = LMMS_VERSION;
if ( createdWith != openedWith )
{
// only one compareType needs to be set, and we can compare on one line because setCompareType returns ProjectVersion
if ( createdWith.setCompareType(Minor) != openedWith)
if( createdWith.setCompareType( ProjectVersion::Minor )
!= openedWith )
{
if( gui != nullptr && root.attribute( "type" ) == "song" )
{
@@ -1045,7 +1046,8 @@ void DataFile::loadData( const QByteArray & _data, const QString & _sourceFile )
}
// the upgrade needs to happen after the warning as it updates the project version.
if( createdWith.setCompareType(Build) < openedWith )
if( createdWith.setCompareType( ProjectVersion::Build )
< openedWith )
{
upgrade();
}

View File

@@ -42,14 +42,21 @@ int parseMinor(QString & version) {
int parseRelease(QString & version) {
return version.section( '.', 2 ).section( '-', 0, 0 ).toInt();
return version.section( '.', 2, 2 ).section( '-', 0, 0 ).toInt();
}
QString parseBuild(QString & version) {
return version.section( '.', 2 ).section( '-', 1 );
QString parseStage(QString & version) {
return version.section( '.', 2, 2 ).section( '-', 1 );
}
int parseBuild(QString & version) {
return version.section( '.', 3 ).toInt();
}
@@ -59,7 +66,8 @@ ProjectVersion::ProjectVersion(QString version, CompareType c) :
m_version(version),
m_major(parseMajor(m_version)),
m_minor(parseMinor(m_version)),
m_release(parseRelease(m_version)) ,
m_release(parseRelease(m_version)),
m_stage(parseStage(m_version)),
m_build(parseBuild(m_version)),
m_compareType(c)
{
@@ -73,6 +81,7 @@ ProjectVersion::ProjectVersion(const char* version, CompareType c) :
m_major(parseMajor(m_version)),
m_minor(parseMinor(m_version)),
m_release(parseRelease(m_version)),
m_stage(parseStage(m_version)),
m_build(parseBuild(m_version)),
m_compareType(c)
{
@@ -87,8 +96,7 @@ int ProjectVersion::compare(const ProjectVersion & a, const ProjectVersion & b,
{
return a.getMajor() - b.getMajor();
}
else if(c == CompareType::Major)
if(c == Major)
{
return 0;
}
@@ -97,7 +105,7 @@ int ProjectVersion::compare(const ProjectVersion & a, const ProjectVersion & b,
{
return a.getMinor() - b.getMinor();
}
else if(c == CompareType::Minor)
if(c == Minor)
{
return 0;
}
@@ -106,23 +114,36 @@ int ProjectVersion::compare(const ProjectVersion & a, const ProjectVersion & b,
{
return a.getRelease() - b.getRelease();
}
else if(c == CompareType::Release)
if(c == Release)
{
return 0;
}
// make sure 0.x.y > 0.x.y-alpha
if(a.getBuild().isEmpty())
if(!(a.getStage().isEmpty() && b.getStage().isEmpty()))
{
return 1;
// make sure 0.x.y > 0.x.y-alpha
if(a.getStage().isEmpty())
{
return 1;
}
if(b.getStage().isEmpty())
{
return -1;
}
// 0.x.y-beta > 0.x.y-alpha
int cmp = QString::compare(a.getStage(), b.getStage());
if(cmp)
{
return cmp;
}
}
if(b.getBuild().isEmpty())
if(c == Stage)
{
return -1;
return 0;
}
// 0.x.y-beta > 0.x.y-alpha
return QString::compare(a.getBuild(), b.getBuild());
return a.getBuild() - b.getBuild();
}

View File

@@ -1,6 +1,2 @@
#define LMMS_VERSION_MAJOR @VERSION_MAJOR@
#define LMMS_VERSION_MINOR @VERSION_MINOR@
#define LMMS_VERSION_PATCH @VERSION_PATCH@
#define LMMS_VERSION_SUFFIX "@VERSION_SUFFIX@"
#define LMMS_VERSION "@VERSION@"
#define LMMS_PROJECT_COPYRIGHT "@PROJECT_COPYRIGHT@"