Skip to content

Commit

Permalink
Pull time from git.
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeWharton committed Jan 5, 2016
1 parent 00cc179 commit ea96470
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ repositories {
}

def gitSha = 'git rev-parse --short HEAD'.execute([], project.rootDir).text.trim()
def buildTime = new Date().format("yyyy-MM-dd'T'HH:mm:ss'Z'", TimeZone.getTimeZone("UTC"))
def gitTimestamp = 'git log -n 1 --format=%at'.execute([], rootDir).text.trim()

def isCi = "true".equals(System.getenv("CI"))
def preDexEnabled = "true".equals(System.getProperty("pre-dex", "true"))
Expand Down Expand Up @@ -73,8 +73,8 @@ android {

signingConfig signingConfigs.u2020

buildConfigField "String", "GIT_SHA", "\"${gitSha}\""
buildConfigField "String", "BUILD_TIME", "\"${buildTime}\""
buildConfigField 'String', 'GIT_SHA', "\"${gitSha}\""
buildConfigField 'long', 'GIT_TIMESTAMP', "${gitTimestamp}"

testInstrumentationRunner "com.jakewharton.u2020.U2020TestRunner"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import javax.inject.Named;
import okhttp3.Cache;
import okhttp3.OkHttpClient;
import org.threeten.bp.Instant;
import org.threeten.bp.ZoneId;
import org.threeten.bp.format.DateTimeFormatter;
import org.threeten.bp.temporal.TemporalAccessor;
Expand All @@ -67,7 +68,6 @@

import static butterknife.ButterKnife.findById;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.threeten.bp.format.DateTimeFormatter.ISO_INSTANT;

public final class DebugView extends FrameLayout {
private static final DateTimeFormatter DATE_DISPLAY_FORMAT =
Expand Down Expand Up @@ -400,7 +400,7 @@ private void setupBuildSection() {
buildCodeView.setText(String.valueOf(BuildConfig.VERSION_CODE));
buildShaView.setText(BuildConfig.GIT_SHA);

TemporalAccessor buildTime = ISO_INSTANT.parse(BuildConfig.BUILD_TIME);
TemporalAccessor buildTime = Instant.ofEpochSecond(BuildConfig.GIT_TIMESTAMP);
buildDateView.setText(DATE_DISPLAY_FORMAT.format(buildTime));
}

Expand Down

0 comments on commit ea96470

Please sign in to comment.