From 3738ec90ec1728bb805d84cd8b1a68c7c31d06e4 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Mon, 25 Sep 2023 11:37:35 +0100 Subject: update/project/*: unified patch handling Handle patches by a function at include/git.sh Signed-off-by: Leah Rowe --- include/git.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 include/git.sh (limited to 'include/git.sh') diff --git a/include/git.sh b/include/git.sh new file mode 100755 index 00000000..f7026765 --- /dev/null +++ b/include/git.sh @@ -0,0 +1,21 @@ +# SPDX-License-Identifier: GPL-3.0-or-later +# SPDX-FileCopyrightText: 2023 Leah Rowe + +git_am_patches() +{ + sdir="${1}" # assumed to be absolute path + patchdir="${2}" # ditto + _fail="${3}" + ( + cd "${sdir}" || \ + "${_fail}" "apply_patches: !cd \"${sdir}\"" + for patch in "${patchdir}/"*; do + [ -L "${patch}" ] && continue + [ -f "${patch}" ] || continue + if ! git am "${patch}"; then + git am --abort || "${_fail}" "${sdir}: !git am --abort" + "${_fail}" "!git am ${patch} -> ${sdir}" + fi + done + ) +} -- cgit v1.2.1