about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCharadon <dev@iotib.net>2022-10-08 14:57:52 -0400
committerCharadon <dev@iotib.net>2022-10-08 14:57:52 -0400
commit242c66e37760c17d5cac28d473b3d862a1e73379 (patch)
treea5cd61dc7df8f528a674a1dbb93c730fc2eb3b9e
parent3ab7ec9bc605c34dc6ad5994457106b20b72d7ff (diff)
downloaddscip-242c66e37760c17d5cac28d473b3d862a1e73379.tar.gz
dscip: Added COMMIT_DATE variable. This tells the date that CURRENT_COMMIT was made. Format of date is determined by DSCIP_DATE_FORMAT in config.sh
-rwxr-xr-xconfig.sh4
-rwxr-xr-xdscip4
2 files changed, 7 insertions, 1 deletions
diff --git a/config.sh b/config.sh
index 1968a92..81eb7f5 100755
--- a/config.sh
+++ b/config.sh
@@ -31,4 +31,6 @@ export DSCIP_DISREGARD_COMMIT_CHECK="false" # If the script should just rebuild
 export DSCIP_OUTPUT_TO="$WORKING_DIRECTORY/output.txt" # Output to file, default is output.txt
 # Automatically update DSCIP?
 export DSCIP_AUTO_UPDATE="false"
-
+# Set up format for the COMMIT_DATE variable. By default, it's %Y%m%d (YEARMONTHDAY | 20220812)
+# See strftime(3) for more information.
+export DSCIP_DATE_FORMAT="%Y%m%d"
diff --git a/dscip b/dscip
index f009fd4..920fd78 100755
--- a/dscip
+++ b/dscip
@@ -90,6 +90,7 @@ build () {
 		echo "DSCIP_FAILED_CMD=$DSCIP_FAILED_CMD";
 		echo "DSCIP_DAEMON=$DSCIP_DAEMON";
 		echo "DSCIP_DAEMON_FORK=$DSCIP_DAEMON_FORK";
+		echo "DSCIP_DATE_FORMAT=$DSCIP_DATE_FORMAT";
 		echo "DSCIP_SLEEP=$DSCIP_SLEEP";
 		echo "DSCIP_DISREGARD_COMMIT_CHECK=$DSCIP_DISREGARD_COMMIT_CHECK";
 		echo "DSCIP_OUTPUT_TO=$DSCIP_OUTPUT_TO"
@@ -149,6 +150,9 @@ run () {
 		return 0
 	fi
 	export CURRENT_COMMIT
+	GIT_UNIX_TIME="$(git show -s --format=%ct "$CURRENT_COMMIT")"
+	COMMIT_DATE="$(date -d "@$GIT_UNIX_TIME" "+$DSCIP_DATE_FORMAT")"
+	export COMMIT_DATE
 
 	# If LAST_COMMIT doesn't exist, that means it's a first run and we can go ahead and build. #
 	# Or skip the commit check if DSCIP_DISREGARD_COMMIT_CHECK is set to true.