Skip to content
Snippets Groups Projects
Commit bf772802 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Introduce system.git_time

This is the time_t (seconds since Unix epoch, Jan-1-1970 UTC) date/time of the
current (most recent) Git commit used to build the running binary.

If a JS developer wants to check if a build is recent-enough to include some
change, this is the property they should use to check (with >= comparison).
parent 1d0dcbac
No related branches found
No related tags found
1 merge request!455Update branch with changes from master
Pipeline #6322 passed
@git log -1 HEAD --format="#define GIT_HASH \"%%h\"" > git_hash.h
@git log -1 HEAD --format="#define GIT_DATE \"%%cd\"" "--date=format-local:%%b %%d %%Y %%H:%%M" >> git_hash.h
@git log -1 HEAD --format="#define GIT_TIME %%cd" --date=unix >> git_hash.h
@echo #define GIT_BRANCH ^"| tr -d "\r\n" > git_branch.h
@git rev-parse --abbrev-ref HEAD | tr -d "\n" >> git_branch.h
@echo ^" >> git_branch.h
......@@ -634,6 +634,7 @@ static const char* sys_prop_desc[] = {
,"Synchronet Git repository branch name"
,"Synchronet Git repository commit hash"
,"Synchronet Git repository commit date/time"
,"Synchronet Git repository commit date/time (seconds since Unix epoch)"
,"Platform description (e.g. 'Win32', 'Linux', 'FreeBSD')"
,"Architecture description (e.g. 'i386', 'i686', 'x86_64')"
,"Message base library version information"
......@@ -2694,6 +2695,7 @@ static JSBool js_system_resolve(JSContext *cx, JSObject *obj, jsid id)
LAZY_STRING("git_branch", git_branch);
LAZY_STRING("git_hash", git_hash);
LAZY_STRING("git_date", git_date);
LAZY_INTEGER("git_time", git_time);
LAZY_STRING("platform", PLATFORM_DESC);
LAZY_STRING("architecture", ARCHITECTURE_DESC);
......
......@@ -159,6 +159,7 @@ ifneq ($(GIT), NO)
git_hash.h: FORCE ../../.git
$(QUIET)git log -1 HEAD --format="#define GIT_HASH \"%h\"" > $@.tmp
$(QUIET)git log -1 HEAD --format="#define GIT_DATE \"%cd\"" '--date=format-local:%b %d %Y %H:%M' >> $@.tmp
$(QUIET)git log -1 HEAD --format="#define GIT_TIME %cd" --date=unix >> $@.tmp
$(QUIET)test -e $@ && diff $@.tmp $@ || cp $@.tmp $@
$(QUIET)rm -f $@.tmp
......
......@@ -33,6 +33,7 @@ extern "C" {
const char* git_hash = GIT_HASH;
const char* git_date = GIT_DATE;
const time_t git_time = GIT_TIME;
const char* git_branch = GIT_BRANCH;
const char* beta_version = " "; /* Space if non-beta, " beta" otherwise */
......
......@@ -28,6 +28,7 @@ extern "C" {
extern const char* git_hash;
extern const char* git_date;
extern const time_t git_time;
extern const char* git_branch;
extern const char* beta_version;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment