mirror of
https://github.com/s1lentq/ReGameDLL_CS.git
synced 2024-12-27 07:05:38 +03:00
Improved versioning: added info about commit id and commit author.
This commit is contained in:
parent
d20d9a8a78
commit
43c9b2cb8c
@ -30,7 +30,9 @@ if (gitInfo.tag && gitInfo.tag[0] == 'v') {
|
||||
minorVersion: m.group(2) as int,
|
||||
maintenanceVersion: m.group(4) ? (m.group(4) as int) : null,
|
||||
countCommit: gitInfo.countCommit,
|
||||
lastCommitDate: gitInfo.lastCommitDate
|
||||
lastCommitDate: gitInfo.lastCommitDate,
|
||||
commitID: gitInfo.commitID,
|
||||
authorCommit: gitInfo.authorCommit
|
||||
)
|
||||
} else {
|
||||
versionInfo = new RegamedllVersionInfo(
|
||||
@ -38,7 +40,9 @@ if (gitInfo.tag && gitInfo.tag[0] == 'v') {
|
||||
minorVersion: project.minorVersion as int,
|
||||
suffix: 'SNAPSHOT',
|
||||
countCommit: gitInfo.countCommit,
|
||||
lastCommitDate: gitInfo.lastCommitDate
|
||||
lastCommitDate: gitInfo.lastCommitDate,
|
||||
commitID: gitInfo.commitID,
|
||||
authorCommit: gitInfo.authorCommit
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -10,4 +10,6 @@ class GitInfo {
|
||||
String branch
|
||||
String tag
|
||||
Integer countCommit
|
||||
String commitID
|
||||
String authorCommit
|
||||
}
|
||||
|
@ -26,6 +26,18 @@ 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 GitInfo versionForDir(File dir) {
|
||||
FileRepositoryBuilder builder = new FileRepositoryBuilder()
|
||||
Repository repo = builder.setWorkTree(dir)
|
||||
@ -38,17 +50,27 @@ class GitVersioner {
|
||||
}
|
||||
|
||||
def commit = new RevWalk(repo).parseCommit(head)
|
||||
def commitLast = parseCommitLast(repo)
|
||||
int commitCount = getCountCommit(repo)
|
||||
|
||||
def branch = repo.getBranch()
|
||||
def commitDate = new DateTime(1000L * commit.commitTime, DateTimeZone.UTC)
|
||||
int commitCount = getCountCommit(repo);
|
||||
|
||||
if (!commit) {
|
||||
throw new RuntimeException("Can't find last commit.")
|
||||
}
|
||||
|
||||
String tag = repo.tags.find { kv -> kv.value.objectId == commit.id }?.key
|
||||
String headCommitId = commit.getId().abbreviate(7).name();
|
||||
String authorCommit = commitLast.getAuthorIdent().getName();
|
||||
|
||||
return new GitInfo(
|
||||
lastCommitDate: commitDate,
|
||||
branch: branch,
|
||||
tag: tag,
|
||||
countCommit: commitCount
|
||||
countCommit: commitCount,
|
||||
commitID: headCommitId,
|
||||
authorCommit: authorCommit
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,8 @@ class RegamedllVersionInfo {
|
||||
String suffix
|
||||
Integer countCommit
|
||||
DateTime lastCommitDate
|
||||
String commitID
|
||||
String authorCommit
|
||||
|
||||
String format(String versionSeparator, String suffixSeparator, boolean includeSuffix) {
|
||||
StringBuilder sb = new StringBuilder()
|
||||
|
@ -371,6 +371,6 @@ task generateAppVersion {
|
||||
renderedFile.delete()
|
||||
renderedFile.write(content, 'utf-8')
|
||||
|
||||
println 'The current ReGameDLL version is ' + verInfo.asVersion().toString() + ', maven version is ' + verInfo.asMavenVersion().toString();
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -109,6 +109,7 @@ void GameDLL_Version_f()
|
||||
// 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: https://github.com/s1lentq/ReGameDLL_CS/commit/" APP_COMMIT_ID " (" APP_COMMIT_AUTHOR ")\n");
|
||||
}
|
||||
|
||||
void EXT_FUNC GameDLLInit()
|
||||
|
@ -10,6 +10,9 @@
|
||||
\#define VERSION_MAJOR ${verInfo.majorVersion}
|
||||
\#define VERSION_MINOR ${verInfo.minorVersion}
|
||||
|
||||
\#define APP_COMMIT_AUTHOR "${verInfo.authorCommit}"
|
||||
\#define APP_COMMIT_ID "${verInfo.commitID}"
|
||||
|
||||
\#define APP_VERSION_D ${verInfo.format('.', '-', true)}
|
||||
\#define APP_VERSION_C ${verInfo.majorVersion},${verInfo.minorVersion},0,${verInfo.countCommit}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user