From 54a05fc167904c97a3bcbc2aeb4afdb5ad35a379 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Fri, 20 Oct 2023 11:16:25 +0100 Subject: always re-generate .git in lbmk in release archives, .git is excluded but the version and versiondate files are included. from these, the git history is re-created with the exact date (but not taking into account timezone, at present). in this way, lbmk will have git history in a release archive. some build systems, like coreboot, prefer that there be git history available, so this is a nice workaround on those build systems. Signed-off-by: Leah Rowe --- include/err.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/err.sh b/include/err.sh index 12bba8fb..83c88ab9 100755 --- a/include/err.sh +++ b/include/err.sh @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT # SPDX-FileCopyrightText: 2022, 2023 Leah Rowe -version=""; versiondate=""; projectname="" +version=""; versiondate=""; projectname=""; _nogit="" x_() { [ $# -lt 1 ] || ${@} || err_exit err ${@} @@ -27,6 +27,20 @@ check_git() git_err "git config --global user.email \"john.doe@example.com\"" } +# release archives contain .gitignore, but not .git. +# lbmk can be run from lbmk.git, or an archive. +git_init() +{ + [ -L ".git" ] && ${2} "Reference .git is a symlink" + [ -e ".git" ] && return 0 + eval "$(setvars "$(date -Rd @${versiondate})" cdate _nogit)" + + ${1} git init + ${1} git add -A . + ${1} git commit -m "${projectname} ${version}" --date "${cdate}" + ${1} git tag -a "${version}" -m "${projectname} ${version}" +} + git_err() { printf "You need to set git name/email, like so:\n%s\n\n" "${1}" 1>&2 -- cgit v1.2.1