mirror of
https://github.com/s1lentq/ReGameDLL_CS.git
synced 2025-03-03 17:25:24 +03:00
Refactoring versioned
This commit is contained in:
parent
dd3e68fb69
commit
54739c62ab
27
build.gradle
27
build.gradle
@ -1,5 +1,6 @@
|
||||
import versioning.GitVersioner
|
||||
import versioning.RegamedllVersionInfo
|
||||
import org.joda.time.DateTime
|
||||
|
||||
apply plugin: 'maven-publish'
|
||||
apply from: 'shared.gradle'
|
||||
@ -14,10 +15,6 @@ idea {
|
||||
}
|
||||
|
||||
def gitInfo = GitVersioner.versionForDir(project.rootDir)
|
||||
if (!gitInfo) {
|
||||
throw new RuntimeException('Running outside git repository')
|
||||
}
|
||||
|
||||
RegamedllVersionInfo versionInfo
|
||||
if (gitInfo.tag && gitInfo.tag[0] == 'v') {
|
||||
def m = gitInfo.tag =~ /^v(\d+)\.(\d+)(\.(\d+))?$/
|
||||
@ -29,22 +26,22 @@ if (gitInfo.tag && gitInfo.tag[0] == 'v') {
|
||||
majorVersion: m.group(1) as int,
|
||||
minorVersion: m.group(2) as int,
|
||||
maintenanceVersion: m.group(4) ? (m.group(4) as int) : null,
|
||||
countCommit: gitInfo.countCommit,
|
||||
lastCommitDate: gitInfo.lastCommitDate,
|
||||
commitID: gitInfo.commitID,
|
||||
authorCommit: gitInfo.authorCommit,
|
||||
urlCommits: gitInfo.urlCommits
|
||||
localChanges: gitInfo.localChanges,
|
||||
commitDate: gitInfo.commitDate,
|
||||
commitSHA: gitInfo.commitSHA,
|
||||
commitURL: gitInfo.commitURL
|
||||
)
|
||||
} else {
|
||||
versionInfo = new RegamedllVersionInfo(
|
||||
majorVersion: project.majorVersion as int,
|
||||
minorVersion: project.minorVersion as int,
|
||||
suffix: 'SNAPSHOT',
|
||||
countCommit: gitInfo.countCommit,
|
||||
lastCommitDate: gitInfo.lastCommitDate,
|
||||
commitID: gitInfo.commitID,
|
||||
authorCommit: gitInfo.authorCommit,
|
||||
urlCommits: gitInfo.urlCommits
|
||||
maintenanceVersion: project.maintenanceVersion as int,
|
||||
suffix: 'dev',
|
||||
localChanges: gitInfo ? gitInfo.localChanges : true,
|
||||
commitDate: gitInfo ? gitInfo.commitDate : new DateTime(),
|
||||
commitSHA: gitInfo ? gitInfo.commitSHA : "",
|
||||
commitURL: gitInfo ? gitInfo.commitURL : "",
|
||||
commitCount: gitInfo ? (gitInfo.commitCount as int) : null
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,9 @@ repositories {
|
||||
maven {
|
||||
url 'http://nexus.rehlds.org/nexus/content/repositories/regamedll-snapshots/'
|
||||
}
|
||||
maven {
|
||||
url 'http://nexus.rehlds.org/nexus/content/repositories/regamedll-dev/'
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -6,11 +6,11 @@ import org.joda.time.DateTime
|
||||
|
||||
@CompileStatic @TypeChecked
|
||||
class GitInfo {
|
||||
DateTime lastCommitDate
|
||||
boolean localChanges
|
||||
DateTime commitDate
|
||||
String branch
|
||||
String tag
|
||||
Integer countCommit
|
||||
String commitID
|
||||
String authorCommit
|
||||
String urlCommits
|
||||
String commitSHA
|
||||
String commitURL
|
||||
Integer commitCount
|
||||
}
|
||||
|
@ -1,8 +1,11 @@
|
||||
package versioning
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import groovy.transform.CompileStatic
|
||||
import groovy.transform.TypeChecked
|
||||
import org.eclipse.jgit.api.Git
|
||||
import org.eclipse.jgit.api.Status;
|
||||
import org.eclipse.jgit.lib.ObjectId
|
||||
import org.eclipse.jgit.lib.Repository
|
||||
import org.eclipse.jgit.lib.StoredConfig
|
||||
@ -27,18 +30,6 @@ class GitVersioner {
|
||||
|
||||
return count;
|
||||
}
|
||||
// return last commit excluding merge commit
|
||||
static RevCommit parseCommitLast(Repository repo) {
|
||||
Iterable<RevCommit> commits = Git.wrap(repo).log().call()
|
||||
for (RevCommit b : commits) {
|
||||
if (b.getParents().length > 1) { // it's merge commit ignore it
|
||||
continue;
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
static String prepareUrlToCommits(String url) {
|
||||
if (url == null) {
|
||||
// default remote url
|
||||
@ -64,24 +55,42 @@ class GitVersioner {
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
// check uncommited changes
|
||||
static boolean getUncommittedChanges(Repository repo) {
|
||||
Git git = new Git(repo);
|
||||
Status status = git.status().call();
|
||||
|
||||
Set<String> uncommittedChanges = status.getUncommittedChanges();
|
||||
for(String uncommitted : uncommittedChanges) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
static GitInfo versionForDir(File dir) {
|
||||
FileRepositoryBuilder builder = new FileRepositoryBuilder()
|
||||
FileRepositoryBuilder builder = new FileRepositoryBuilder();
|
||||
Repository repo = builder.setWorkTree(dir)
|
||||
.findGitDir()
|
||||
.build()
|
||||
|
||||
ObjectId head = repo.resolve('HEAD')
|
||||
ObjectId head = repo.resolve('HEAD');
|
||||
if (!head) {
|
||||
return null
|
||||
}
|
||||
|
||||
final StoredConfig cfg = repo.getConfig();
|
||||
def commit = new RevWalk(repo).parseCommit(head)
|
||||
def commitLast = parseCommitLast(repo)
|
||||
int commitCount = getCountCommit(repo)
|
||||
def commit = new RevWalk(repo).parseCommit(head);
|
||||
if (!commit) {
|
||||
throw new RuntimeException("Can't find last commit.");
|
||||
}
|
||||
|
||||
def branch = repo.getBranch()
|
||||
def commitDate = new DateTime(1000L * commit.commitTime, DateTimeZone.UTC)
|
||||
def localChanges = getUncommittedChanges(repo);
|
||||
def commitDate = new DateTime(1000L * commit.commitTime, DateTimeZone.UTC);
|
||||
if (localChanges) {
|
||||
commitDate = new DateTime();
|
||||
}
|
||||
|
||||
def branch = repo.getBranch();
|
||||
|
||||
String url = null;
|
||||
String remote_name = cfg.getString("branch", branch, "remote");
|
||||
@ -99,31 +108,18 @@ class GitVersioner {
|
||||
url = cfg.getString("remote", remote_name, "url");
|
||||
}
|
||||
|
||||
println 'Debug: Start';
|
||||
println ' cfg: (' + cfg + ')';
|
||||
println ' branch: (' + branch + ')';
|
||||
println ' remote_name: (' + remote_name + ')';
|
||||
println ' url: (' + url + ')';
|
||||
println 'Debug: End';
|
||||
|
||||
String urlCommits = prepareUrlToCommits(url);
|
||||
|
||||
if (!commit) {
|
||||
throw new RuntimeException("Can't find last commit.")
|
||||
}
|
||||
|
||||
String commitURL = prepareUrlToCommits(url);
|
||||
String tag = repo.tags.find { kv -> kv.value.objectId == commit.id }?.key
|
||||
String headCommitId = commit.getId().abbreviate(7).name();
|
||||
String authorCommit = commitLast.getAuthorIdent().getName();
|
||||
String commitSHA = commit.getId().abbreviate(7).name();
|
||||
|
||||
return new GitInfo(
|
||||
lastCommitDate: commitDate,
|
||||
localChanges: localChanges,
|
||||
commitDate: commitDate,
|
||||
branch: branch,
|
||||
tag: tag,
|
||||
countCommit: commitCount,
|
||||
commitID: headCommitId,
|
||||
authorCommit: authorCommit,
|
||||
urlCommits: urlCommits
|
||||
commitSHA: commitSHA,
|
||||
commitURL: commitURL,
|
||||
commitCount: getCountCommit(repo)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -3,40 +3,54 @@ package versioning
|
||||
import groovy.transform.CompileStatic
|
||||
import groovy.transform.ToString
|
||||
import groovy.transform.TypeChecked
|
||||
import org.joda.time.format.DateTimeFormat
|
||||
import org.joda.time.DateTime
|
||||
|
||||
@CompileStatic @TypeChecked
|
||||
@ToString(includeNames = true)
|
||||
class RegamedllVersionInfo {
|
||||
int majorVersion
|
||||
int minorVersion
|
||||
Integer majorVersion
|
||||
Integer minorVersion
|
||||
Integer maintenanceVersion
|
||||
String suffix
|
||||
Integer countCommit
|
||||
DateTime lastCommitDate
|
||||
String commitID
|
||||
String authorCommit
|
||||
String urlCommits
|
||||
|
||||
String format(String versionSeparator, String suffixSeparator, boolean includeSuffix) {
|
||||
boolean localChanges
|
||||
DateTime commitDate
|
||||
String commitSHA
|
||||
String commitURL
|
||||
Integer commitCount
|
||||
|
||||
String asMavenVersion() {
|
||||
StringBuilder sb = new StringBuilder()
|
||||
sb.append(majorVersion).append(versionSeparator).append(minorVersion)
|
||||
sb.append(majorVersion).append('.' + minorVersion);
|
||||
if (maintenanceVersion != null) {
|
||||
sb.append(versionSeparator).append(maintenanceVersion)
|
||||
sb.append('.' + maintenanceVersion);
|
||||
}
|
||||
|
||||
if (suffix && includeSuffix) {
|
||||
sb.append(suffixSeparator).append(suffix)
|
||||
if (commitCount != null) {
|
||||
sb.append('.' + commitCount)
|
||||
}
|
||||
|
||||
if (suffix) {
|
||||
sb.append('-' + suffix)
|
||||
}
|
||||
|
||||
// do mark for this build like a modified version
|
||||
if (localChanges) {
|
||||
sb.append('+m');
|
||||
}
|
||||
|
||||
return sb.toString()
|
||||
}
|
||||
String asVersion() {
|
||||
StringBuilder sb = new StringBuilder()
|
||||
sb.append(majorVersion).append('.' + minorVersion).append('.' + countCommit);
|
||||
return sb;
|
||||
String asCommitDate() {
|
||||
String pattern = "MMM d yyyy";
|
||||
if (commitDate.getDayOfMonth() >= 10) {
|
||||
pattern = "MMM d yyyy";
|
||||
}
|
||||
String asMavenVersion() {
|
||||
format('.', '-', true)
|
||||
|
||||
return DateTimeFormat.forPattern(pattern).withLocale(Locale.ENGLISH).print(commitDate);
|
||||
}
|
||||
String asCommitTime() {
|
||||
return DateTimeFormat.forPattern('HH:mm:ss').withLocale(Locale.ENGLISH).print(commitDate);
|
||||
}
|
||||
}
|
||||
|
@ -1,2 +1,3 @@
|
||||
majorVersion=0
|
||||
minorVersion=2
|
||||
majorVersion=5
|
||||
minorVersion=0
|
||||
maintenanceVersion=0
|
||||
|
@ -11,7 +11,6 @@ void _copyFile(String from, String to) {
|
||||
}
|
||||
|
||||
task publishPrepareFiles {
|
||||
//dependsOn ':flightrec/decoder:uberjar'
|
||||
doLast {
|
||||
def pubRootDir = project.file('publish/publishRoot')
|
||||
if (pubRootDir.exists()) {
|
||||
@ -72,6 +71,11 @@ publishing {
|
||||
resolveStrategy = DELEGATE_FIRST
|
||||
name project.name
|
||||
description project.description
|
||||
properties {
|
||||
commitDate project.ext.regamedllVersionInfo.commitDate
|
||||
commitSHA project.ext.regamedllVersionInfo.commitSHA
|
||||
}
|
||||
|
||||
//url github
|
||||
//scm {
|
||||
// url "${github}.git"
|
||||
@ -110,8 +114,8 @@ if (file('repo_creds.properties').exists()) {
|
||||
publishing {
|
||||
repositories {
|
||||
maven {
|
||||
if (project.version.contains('SNAPSHOT')) {
|
||||
url "http://nexus.rehlds.org/nexus/content/repositories/regamedll-snapshots/"
|
||||
if (project.version.contains('dev')) {
|
||||
url "http://nexus.rehlds.org/nexus/content/repositories/regamedll-dev/"
|
||||
} else {
|
||||
url "http://nexus.rehlds.org/nexus/content/repositories/regamedll-releases/"
|
||||
}
|
||||
@ -127,6 +131,5 @@ task doPublish {
|
||||
dependsOn 'publishPackage'
|
||||
if (repoCreds.getProperty('username') && repoCreds.getProperty('password')) {
|
||||
dependsOn 'publish'
|
||||
//dependsOn ':flightrec/decoder_api:publish'
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
import gradlecpp.RegamedllPlayTestPlugin
|
||||
import gradlecpp.RegamedllPlayTestTask
|
||||
import gradlecpp.VelocityUtils
|
||||
|
||||
import org.doomedsociety.gradlecpp.GradleCppUtils
|
||||
import org.doomedsociety.gradlecpp.LazyNativeDepSet
|
||||
import org.doomedsociety.gradlecpp.cfg.ToolchainConfig
|
||||
@ -377,11 +378,14 @@ task generateAppVersion {
|
||||
def tplFile = project.file('version/appversion.vm')
|
||||
def renderedFile = project.file('version/appversion.h')
|
||||
|
||||
// check to up-to-date
|
||||
inputs.file tplFile
|
||||
inputs.file project.file('gradle.properties')
|
||||
outputs.file renderedFile
|
||||
inputs.property('version', verInfo.asMavenVersion())
|
||||
inputs.property('lastCommitDate', verInfo.lastCommitDate.toString())
|
||||
|
||||
// this will ensure that this task is redone when the versions change
|
||||
inputs.property('version', rootProject.version)
|
||||
inputs.property('commitDate', verInfo.asCommitDate())
|
||||
|
||||
doLast {
|
||||
def templateCtx = [
|
||||
@ -389,10 +393,9 @@ task generateAppVersion {
|
||||
]
|
||||
|
||||
def content = VelocityUtils.renderTemplate(tplFile, templateCtx)
|
||||
|
||||
renderedFile.delete()
|
||||
renderedFile.write(content, 'utf-8')
|
||||
|
||||
println 'The current ReGameDLL version is ' + verInfo.asVersion().toString() + ', maven version is ' + verInfo.asMavenVersion().toString() + ', commit id: ' + verInfo.commitID.toString() + ', commit author: ' + verInfo.authorCommit.toString() + ', url: (' + verInfo.urlCommits.toString() + ')';
|
||||
println 'The current ReGameDLL maven version is ' + rootProject.version + ', url: (' + verInfo.commitURL + '' + verInfo.commitSHA + ')';
|
||||
}
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ cvar_t sk_scientist_heal3 = { "sk_scientist_heal3", "0", 0, 0.0f, NULL };
|
||||
|
||||
#ifdef REGAMEDLL_ADD
|
||||
|
||||
cvar_t game_version = { "game_version", APP_VERSION_STRD, FCVAR_SERVER, 0.0f, nullptr };
|
||||
cvar_t game_version = { "game_version", APP_VERSION, FCVAR_SERVER, 0.0f, nullptr };
|
||||
cvar_t maxmoney = { "mp_maxmoney", "16000", FCVAR_SERVER, 0.0f, nullptr };
|
||||
cvar_t round_infinite = { "mp_round_infinite", "0", FCVAR_SERVER, 0.0f, nullptr };
|
||||
cvar_t hegrenade_penetration = { "mp_hegrenade_penetration", "0", 0, 0.0f, nullptr };
|
||||
@ -123,9 +123,9 @@ void GameDLL_Version_f()
|
||||
return;
|
||||
|
||||
// print version
|
||||
CONSOLE_ECHO("ReGameDLL build: " __TIME__ " " __DATE__ " (" APP_VERSION_STRD ")\n");
|
||||
CONSOLE_ECHO("ReGameDLL API version %i.%i\n", REGAMEDLL_API_VERSION_MAJOR, REGAMEDLL_API_VERSION_MINOR);
|
||||
CONSOLE_ECHO("Build from: " APP_COMMITS_URL APP_COMMIT_ID " " APP_COMMIT_AUTHOR "\n");
|
||||
CONSOLE_ECHO("ReGameDLL version: " APP_VERSION "\n");
|
||||
CONSOLE_ECHO("Build date: " APP_COMMIT_TIME " " APP_COMMIT_DATE "\n");
|
||||
CONSOLE_ECHO("Build from: " APP_COMMIT_URL APP_COMMIT_SHA "\n");
|
||||
}
|
||||
|
||||
void GameDLL_EndRound_f()
|
||||
@ -264,8 +264,7 @@ void EXT_FUNC GameDLLInit()
|
||||
CVAR_REGISTER(&forcerespawn);
|
||||
|
||||
// print version
|
||||
CONSOLE_ECHO("ReGameDLL build: " __TIME__ " " __DATE__ " (" APP_VERSION_STRD ")\n");
|
||||
CONSOLE_ECHO("ReGameDLL API version %i.%i\n", REGAMEDLL_API_VERSION_MAJOR, REGAMEDLL_API_VERSION_MINOR);
|
||||
CONSOLE_ECHO("ReGameDLL version: " APP_VERSION "\n");
|
||||
|
||||
#endif // REGAMEDLL_ADD
|
||||
|
||||
|
@ -8,22 +8,26 @@ set srcdir=%~1
|
||||
set repodir=%~2
|
||||
|
||||
set old_version=
|
||||
set old_specialbuild=""
|
||||
set version_revision=0
|
||||
set version_specialbuild=
|
||||
set version_id_commit=
|
||||
set version_author_commit=
|
||||
set version_pdate_1=%date:~-4%-%date:~3,2%-%date:~0,2%
|
||||
set version_pdate=%version_pdate_1%%time:~0,2%:%time:~3,2%:%time:~6,2%
|
||||
set version_pdate_2=%time:~0,2%-%time:~3,2%-%time:~6,2%
|
||||
set version_pdate_2=%version_pdate_2: =%
|
||||
set version_date=%version_pdate_1%__%version_pdate_2%
|
||||
set version_major=0
|
||||
set version_minor=0
|
||||
set version_specialversion=
|
||||
set url_commit=
|
||||
set version_maintenance=0
|
||||
set version_modifed=
|
||||
|
||||
set commitSHA=
|
||||
set commitURL=
|
||||
set commitCount=0
|
||||
set branch_name=master
|
||||
|
||||
for /f "delims=" %%a in ('wmic OS Get localdatetime ^| find "."') do set "dt=%%a"
|
||||
set "YYYY=%dt:~0,4%"
|
||||
set "MM=%dt:~4,2%"
|
||||
set "DD=%dt:~6,2%"
|
||||
set "hour=%dt:~8,2%"
|
||||
set "min=%dt:~10,2%"
|
||||
set "sec=%dt:~12,2%"
|
||||
|
||||
for /f "tokens=%MM%" %%I in ("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec") do set "month=%%I"
|
||||
|
||||
::
|
||||
:: Check for git.exe presence
|
||||
::
|
||||
@ -36,8 +40,11 @@ set errlvl="%ERRORLEVEL%"
|
||||
IF EXIST "%srcdir%\appversion.h" (
|
||||
FOR /F "usebackq tokens=1,2,3" %%i in ("%srcdir%\appversion.h") do (
|
||||
IF %%i==#define (
|
||||
IF %%j==APP_VERSION_C set old_version=%%k
|
||||
IF %%j==APP_VERSION_SPECIALBUILD set old_specialbuild=%%k
|
||||
IF %%j==APP_VERSION (
|
||||
:: Remove quotes
|
||||
set v=%%k
|
||||
set old_version=!v:"=!
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -47,7 +54,7 @@ IF %errlvl% == "1" (
|
||||
|
||||
:: if we haven't appversion.h, we need to create it
|
||||
IF NOT "%old_version%" == "" (
|
||||
set version_revision=0
|
||||
set commitCount=0
|
||||
)
|
||||
)
|
||||
|
||||
@ -59,7 +66,7 @@ IF EXIST "%srcdir%\version.h" (
|
||||
IF %%i==#define (
|
||||
IF %%j==VERSION_MAJOR set version_major=%%k
|
||||
IF %%j==VERSION_MINOR set version_minor=%%k
|
||||
IF %%j==VERSION_SPECIALVERSION set version_specialversion=%%k
|
||||
IF %%j==VERSION_MAINTENANCE set version_maintenance=%%k
|
||||
)
|
||||
)
|
||||
) ELSE (
|
||||
@ -67,7 +74,7 @@ IF EXIST "%srcdir%\version.h" (
|
||||
IF NOT [%%j] == [] (
|
||||
IF %%i==majorVersion set version_major=%%j
|
||||
IF %%i==minorVersion set version_minor=%%j
|
||||
IF %%i==specialVersion set version_specialversion=%%j
|
||||
IF %%i==maintenanceVersion set version_maintenance=%%j
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -83,17 +90,11 @@ IF NOT %errlvl% == "1" (
|
||||
|
||||
FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." rev-list --count !branch_name!"') DO (
|
||||
IF NOT [%%i] == [] (
|
||||
set version_revision=%%i
|
||||
set commitCount=%%i
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
::
|
||||
:: Now form full version string like 1.0.0.1
|
||||
::
|
||||
|
||||
set new_version=%version_major%,%version_minor%,0,%version_revision%
|
||||
|
||||
::
|
||||
:: Get remote url repository
|
||||
::
|
||||
@ -106,49 +107,45 @@ IF NOT %errlvl% == "1" (
|
||||
)
|
||||
:: Get remote url
|
||||
FOR /F "tokens=2 delims=@" %%i IN ('"git -C "%repodir%\." config remote.!branch_remote!.url"') DO (
|
||||
set url_commit=%%i
|
||||
)
|
||||
:: Get author last no-merge commit
|
||||
FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." log -1 --no-merges --pretty=format:%%an"') DO (
|
||||
set version_author_commit=%%i
|
||||
set commitURL=%%i
|
||||
)
|
||||
:: Get commit id
|
||||
FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." rev-parse --verify HEAD"') DO (
|
||||
set var=%%i
|
||||
set version_id_commit=!var:~0,+7!
|
||||
set shafull=%%i
|
||||
set commitSHA=!shafull:~0,+7!
|
||||
)
|
||||
|
||||
IF [!url_commit!] == [] (
|
||||
IF [!commitURL!] == [] (
|
||||
|
||||
FOR /F "tokens=1" %%i IN ('"git -C "%repodir%\." config remote.!branch_remote!.url"') DO (
|
||||
set url_commit=%%i
|
||||
set commitURL=%%i
|
||||
)
|
||||
|
||||
:: strip .git
|
||||
if "x!url_commit:~-4!"=="x.git" (
|
||||
set url_commit=!url_commit:~0,-4!
|
||||
if "x!commitURL:~-4!"=="x.git" (
|
||||
set commitURL=!commitURL:~0,-4!
|
||||
)
|
||||
|
||||
:: append extra string
|
||||
If NOT "%url_commit%"=="%url_commit:bitbucket.org=%" (
|
||||
set url_commit=!url_commit!/commit/
|
||||
If NOT "%commitURL%"=="%commitURL:bitbucket.org=%" (
|
||||
set commitURL=!commitURL!/commit/
|
||||
) ELSE (
|
||||
set url_commit=!url_commit!/commits/
|
||||
set commitURL=!commitURL!/commits/
|
||||
)
|
||||
|
||||
) ELSE (
|
||||
:: strip .git
|
||||
if "x!url_commit:~-4!"=="x.git" (
|
||||
set url_commit=!url_commit:~0,-4!
|
||||
if "x!commitURL:~-4!"=="x.git" (
|
||||
set commitURL=!commitURL:~0,-4!
|
||||
)
|
||||
:: replace : to /
|
||||
set url_commit=!url_commit::=/!
|
||||
set commitURL=!commitURL::=/!
|
||||
|
||||
:: append extra string
|
||||
If NOT "%url_commit%"=="%url_commit:bitbucket.org=%" (
|
||||
set url_commit=https://!url_commit!/commit/
|
||||
If NOT "%commitURL%"=="%commitURL:bitbucket.org=%" (
|
||||
set commitURL=https://!commitURL!/commit/
|
||||
) ELSE (
|
||||
set url_commit=https://!url_commit!/commits/
|
||||
set commitURL=https://!commitURL!/commits/
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -164,25 +161,23 @@ IF NOT %errlvl% == "1" (
|
||||
)
|
||||
|
||||
IF [%localChanged%]==[1] (
|
||||
IF NOT [%version_specialversion%] == [] (
|
||||
set version_specialbuild=%version_specialversion%
|
||||
) ELSE (
|
||||
set version_specialbuild=m
|
||||
)
|
||||
) ELSE (
|
||||
set version_specialbuild=
|
||||
set version_modifed=+m
|
||||
)
|
||||
|
||||
::
|
||||
:: Now form full version string like 1.0.0.1
|
||||
::
|
||||
|
||||
set new_version=%version_major%.%version_minor%.%version_maintenance%.%commitCount%-dev%version_modifed%
|
||||
|
||||
::
|
||||
:: Update appversion.h if version has changed or modifications/mixed revisions detected
|
||||
::
|
||||
IF NOT "%new_version%"=="%old_version%" goto _update
|
||||
IF NOT "%version_specialbuild%"==%old_specialbuild% goto _update
|
||||
goto _exit
|
||||
|
||||
:_update
|
||||
echo Updating appversion.h, new version is "%new_version%", the old one was "%old_version%"
|
||||
echo new special build is "%version_specialbuild%", the old one was %old_specialbuild%
|
||||
echo Updating appversion.h, new version is "%new_version%", the old one was %old_version%
|
||||
|
||||
echo #ifndef __APPVERSION_H__>"%srcdir%\appversion.h"
|
||||
echo #define __APPVERSION_H__>>"%srcdir%\appversion.h"
|
||||
@ -193,40 +188,15 @@ echo // Don't edit it.>>"%srcdir%\appversion.h"
|
||||
echo // >>"%srcdir%\appversion.h"
|
||||
echo.>>"%srcdir%\appversion.h"
|
||||
echo // Version defines>>"%srcdir%\appversion.h"
|
||||
|
||||
IF "%version_specialversion%" == "" (
|
||||
echo #define APP_VERSION_D %version_major%.%version_minor%.%version_revision% >>"%srcdir%\appversion.h"
|
||||
echo #define APP_VERSION_STRD "%version_major%.%version_minor%.%version_revision%">>"%srcdir%\appversion.h"
|
||||
echo #define APP_VERSION_STRD_RC "%version_major%.%version_minor%.%version_revision%">>"%srcdir%\appversion.h"
|
||||
echo #define APP_VERSION_C %version_major%,%version_minor%,0,%version_revision% >>"%srcdir%\appversion.h"
|
||||
echo #define APP_VERSION_STRCS "%version_major%,%version_minor%,0,%version_revision%">>"%srcdir%\appversion.h"
|
||||
) ELSE (
|
||||
echo #define APP_VERSION_D %version_major%.%version_minor%.%version_maintenance%.%version_revision% >>"%srcdir%\appversion.h"
|
||||
echo #define APP_VERSION_STRD "%version_major%.%version_minor%.%version_maintenance%.%version_revision%">>"%srcdir%\appversion.h"
|
||||
echo #define APP_VERSION_STRD_RC "%version_major%.%version_minor%.%version_maintenance%.%version_revision%">>"%srcdir%\appversion.h"
|
||||
echo #define APP_VERSION_C %version_major%,%version_minor%,%version_maintenance%,%version_revision% >>"%srcdir%\appversion.h"
|
||||
echo #define APP_VERSION_STRCS "%version_major%,%version_minor%,%version_maintenance%,%version_revision%">>"%srcdir%\appversion.h"
|
||||
)
|
||||
echo #define APP_VERSION "%new_version%">>"%srcdir%\appversion.h"
|
||||
|
||||
echo.>>"%srcdir%\appversion.h"
|
||||
echo #define APP_VERSION_DATE %version_date%>>"%srcdir%\appversion.h"
|
||||
echo #define APP_VERSION_DATE_STR "%version_date%">>"%srcdir%\appversion.h"
|
||||
echo #define APP_VERSION_PDATE_STR "%version_pdate%">>"%srcdir%\appversion.h"
|
||||
echo #define APP_VERSION_YMD_STR "%version_pdate_1%">>"%srcdir%\appversion.h"
|
||||
echo.>>"%srcdir%\appversion.h"
|
||||
echo #define APP_COMMIT_AUTHOR "(%version_author_commit%)">>"%srcdir%\appversion.h"
|
||||
echo #define APP_COMMIT_ID "%version_id_commit%">>"%srcdir%\appversion.h"
|
||||
echo #define APP_COMMITS_URL "%url_commit%">>"%srcdir%\appversion.h"
|
||||
echo.>>"%srcdir%\appversion.h"
|
||||
echo #define APP_COMMIT_DATE "%month% %DD% %YYYY%">>"%srcdir%\appversion.h"
|
||||
echo #define APP_COMMIT_TIME "%hour%:%min%:%sec%">>"%srcdir%\appversion.h"
|
||||
|
||||
IF NOT "%version_specialbuild%" == "" (
|
||||
echo #define APP_VERSION_FLAGS VS_FF_SPECIALBUILD>>"%srcdir%\appversion.h"
|
||||
echo #define APP_VERSION_SPECIALBUILD "%version_specialbuild%">>"%srcdir%\appversion.h"
|
||||
echo #define APP_VERSION APP_VERSION_STRD "" APP_VERSION_SPECIALBUILD>>"%srcdir%\appversion.h"
|
||||
) ELSE (
|
||||
echo #define APP_VERSION_FLAGS 0x0L>>"%srcdir%\appversion.h"
|
||||
echo #define APP_VERSION APP_VERSION_STRD>>"%srcdir%\appversion.h"
|
||||
)
|
||||
echo.>>"%srcdir%\appversion.h"
|
||||
echo #define APP_COMMIT_SHA "%commitSHA%">>"%srcdir%\appversion.h"
|
||||
echo #define APP_COMMIT_URL "%commitURL%">>"%srcdir%\appversion.h"
|
||||
echo.>>"%srcdir%\appversion.h"
|
||||
|
||||
echo #endif //__APPVERSION_H__>>"%srcdir%\appversion.h"
|
||||
|
@ -7,21 +7,12 @@
|
||||
//
|
||||
|
||||
// Version defines
|
||||
\#define VERSION_MAJOR ${verInfo.majorVersion}
|
||||
\#define VERSION_MINOR ${verInfo.minorVersion}
|
||||
\#define APP_VERSION "$verInfo.asMavenVersion()"
|
||||
|
||||
\#define APP_COMMIT_AUTHOR "(${verInfo.authorCommit})"
|
||||
\#define APP_COMMIT_ID "${verInfo.commitID}"
|
||||
\#define APP_COMMITS_URL "${verInfo.urlCommits}"
|
||||
\#define APP_COMMIT_DATE "$verInfo.asCommitDate()"
|
||||
\#define APP_COMMIT_TIME "$verInfo.asCommitTime()"
|
||||
|
||||
\#define APP_VERSION_D ${verInfo.format('.', '-', true)}
|
||||
\#define APP_VERSION_C ${verInfo.majorVersion},${verInfo.minorVersion},0,${verInfo.countCommit}
|
||||
|
||||
\#define APP_VERSION_STRD "${verInfo.majorVersion}.${verInfo.minorVersion}.${verInfo.countCommit}"
|
||||
\#define APP_VERSION_STRD_RC "${verInfo.majorVersion}.${verInfo.minorVersion}.${verInfo.countCommit}"
|
||||
#set ( $commitYMD = $_DateTimeFormat.forPattern('yyyy-MM-dd').print($verInfo.lastCommitDate) )
|
||||
|
||||
\#define APP_VERSION_YMD_STR "${commitYMD}"
|
||||
\#define APP_VERSION APP_VERSION_STRD
|
||||
\#define APP_COMMIT_SHA "$verInfo.commitSHA"
|
||||
\#define APP_COMMIT_URL "$verInfo.commitURL"
|
||||
|
||||
#endif //__APPVERSION_H__
|
||||
|
Loading…
x
Reference in New Issue
Block a user