#!/bin/bash

## Copyright (C) 2012 - 2025 ENCRYPTED SUPPORT LLC <adrelanos@whonix.org>
## See the file COPYING for copying conditions.

set -x
set -o errexit
set -o nounset
set -o pipefail
set -o errtrace
shopt -s inherit_errexit

true "INFO: Currently running script: ${BASH_SOURCE[0]} $*"

source /usr/libexec/helper-scripts/git.sh

## XXX: hardcoded path
derivative_maker_source_code_dir="$HOME/derivative-maker"

## XXX: hardcoded path
cd -- "$HOME/derivative-maker/packages/kicksecure/timesanitycheck"

./usr/share/timesanitycheck/date-minimum-file-create

if nothing_to_commit; then
  exit 0
fi

git diff HEAD

## Interactive gate: this script is meant to be run by hand. The
## read blocks until the operator presses enter, giving them a
## chance to inspect the diff before the commit. Non-interactive
## runs (CI etc.) will hang here.
true "press enter to continue"
read -r temp

git add -- 'usr/share/timesanitycheck/minimum_unixtime'
git commit -m 'update minimum_unixtime'

true "$0: INFO: OK"
