1
0
mirror of https://github.com/falk-werner/webfuse-provider synced 2024-10-27 20:44:10 +00:00
falk-werner_webfuse-provider/bin/get_source_date_epoch

41 lines
859 B
Plaintext
Raw Normal View History

#!/bin/sh
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file is part of dobuild.
# Copyright (c) 2019 Contributors as noted in the AUTHORS file.
#
# SPDX-License-Identifier: MPL-2.0
exec 0<&-
set -e
export LANG=C
export LC_ALL=C
TOPDIR="$1"
[ -z "$TOPDIR" ] || cd "$TOPDIR"
try_git() {
[ -d .git ] || return 1
git show -s --format=format:%ct HEAD
}
try_svn() {
[ -d .svn ] || return 1
LAST_CHANGED_DATE="$(svn info | sed -n -e 's/^Last Changed Date: //p')"
[ -n "$LAST_CHANGED_DATE" ] || return 2
SOURCE_DATE_EPOCH="$(date -d "$LAST_CHANGED_DATE" +%s)"
}
try_mtime() {
stat -c '%Y' "$PWD"
}
SOURCE_DATE_EPOCH="$(try_git || try_svn || try_mtime)"
echo "$SOURCE_DATE_EPOCH"