Build nightly changelog from git
This commit is contained in:
parent
942e853ca7
commit
7fb34eb262
|
@ -14,6 +14,7 @@ tasks.withType(Test) {
|
||||||
systemProperty "logback.configurationFile", System.getProperty("user.dir", null) + "/app/src/main/assets/logback.xml"
|
systemProperty "logback.configurationFile", System.getProperty("user.dir", null) + "/app/src/main/assets/logback.xml"
|
||||||
systemProperty "GB_LOGFILES_DIR", Files.createTempDirectory("gblog").toString()
|
systemProperty "GB_LOGFILES_DIR", Files.createTempDirectory("gblog").toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
def getVersionCode = { ->
|
def getVersionCode = { ->
|
||||||
try {
|
try {
|
||||||
def stdout = new ByteArrayOutputStream()
|
def stdout = new ByteArrayOutputStream()
|
||||||
|
@ -27,6 +28,27 @@ def getVersionCode = { ->
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def buildGitChangelog = {
|
||||||
|
def stdout = new ByteArrayOutputStream()
|
||||||
|
exec {
|
||||||
|
commandLine 'git', 'log', '--pretty=format:%h %s'
|
||||||
|
standardOutput = stdout
|
||||||
|
}
|
||||||
|
|
||||||
|
def commitVersionCode = getVersionCode()
|
||||||
|
def changelogNode = new Node(null, 'changelog')
|
||||||
|
|
||||||
|
stdout.toString().trim().eachLine { line ->
|
||||||
|
def (commitHash, commitMessage) = line.split(" ", 2)
|
||||||
|
def releaseNode = new Node(changelogNode, 'release', [version: commitHash, versioncode: commitVersionCode--])
|
||||||
|
def _ = new Node(releaseNode, 'change', [:], commitMessage)
|
||||||
|
}
|
||||||
|
|
||||||
|
def changelogFile = new File("${project.rootDir}/app/build/generated/res/changelog/xml/changelog_git.xml")
|
||||||
|
changelogFile.getParentFile().mkdirs()
|
||||||
|
changelogFile.write(groovy.xml.XmlUtil.serialize(changelogNode))
|
||||||
|
}
|
||||||
|
|
||||||
def getGitHashShort = { ->
|
def getGitHashShort = { ->
|
||||||
try {
|
try {
|
||||||
def stdout = new ByteArrayOutputStream()
|
def stdout = new ByteArrayOutputStream()
|
||||||
|
@ -106,6 +128,12 @@ android {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
main {
|
||||||
|
res.srcDirs += "build/generated/res/changelog"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
minifyEnabled true
|
minifyEnabled true
|
||||||
|
@ -170,6 +198,7 @@ android {
|
||||||
|
|
||||||
applicationVariants.all { variant ->
|
applicationVariants.all { variant ->
|
||||||
variant.resValue "string", "applicationId", variant.applicationId
|
variant.resValue "string", "applicationId", variant.applicationId
|
||||||
|
buildGitChangelog()
|
||||||
|
|
||||||
if (variant.buildType.name == 'nightly' || variant.buildType.name == 'nopebble') {
|
if (variant.buildType.name == 'nightly' || variant.buildType.name == 'nopebble') {
|
||||||
variant.outputs.all {
|
variant.outputs.all {
|
||||||
|
|
|
@ -1380,6 +1380,10 @@ public class GBApplication extends Application {
|
||||||
return language;
|
return language;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isNightly() {
|
||||||
|
return BuildConfig.APPLICATION_ID.contains("nightly");
|
||||||
|
}
|
||||||
|
|
||||||
public String getVersion() {
|
public String getVersion() {
|
||||||
try {
|
try {
|
||||||
return getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_META_DATA).versionName;
|
return getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_META_DATA).versionName;
|
||||||
|
|
|
@ -18,20 +18,41 @@ package nodomain.freeyourgadget.gadgetbridge.util;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
import android.util.SparseArray;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import de.cketti.library.changelog.ChangeLog;
|
import de.cketti.library.changelog.ChangeLog;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
|
|
||||||
public class GBChangeLog extends ChangeLog {
|
public class GBChangeLog extends ChangeLog {
|
||||||
|
private static final Logger LOG = LoggerFactory.getLogger(GBChangeLog.class);
|
||||||
|
|
||||||
public GBChangeLog(Context context, String css) {
|
public GBChangeLog(Context context, String css) {
|
||||||
super(context, css);
|
super(context, css);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected SparseArray<ReleaseItem> getMasterChangeLog(boolean full) {
|
||||||
|
if (GBApplication.isNightly()) {
|
||||||
|
try {
|
||||||
|
return readChangeLogFromResource(R.xml.changelog_git, full);
|
||||||
|
} catch (final Exception e) {
|
||||||
|
// Just in case the git changelog is broken somehow..
|
||||||
|
LOG.error("Failed to read git changelog for nightly", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.getMasterChangeLog(full);
|
||||||
|
}
|
||||||
|
|
||||||
public AlertDialog getMaterialLogDialog() {
|
public AlertDialog getMaterialLogDialog() {
|
||||||
return getMaterialDialog(isFirstRunEver());
|
return getMaterialDialog(isFirstRunEver());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue