blob: c9cbc8be860ff6ce5bae3f3b381a2324a780ef80 [file] [log] [blame]
# Copyright 2020 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
OUTFILE=$1
GIT_DIR=$2
VERSION_INFO="$(TZ=UTC git --git-dir=$GIT_DIR show --no-patch --no-notes --pretty='%H-%ct' HEAD 2> /dev/null)"
# Update the existing file only if it's changed.
if [ ! -r "$OUTFILE" ] || [ "$(<"$OUTFILE")" != "$VERSION_INFO" ]; then
echo "$VERSION_INFO" > "$OUTFILE"
fi