-
Notifications
You must be signed in to change notification settings - Fork 1
/
format_patch.sh
executable file
·40 lines (30 loc) · 1.03 KB
/
format_patch.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
if [[ "$#" -lt 1 ]]; then
echo "${0} patchfile: format the patch file"
exit 2
fi
source "$(dirname "${BASH_SOURCE}")/helper.sh"
cd "${ROOT}"
PATCH_PATH=$1
PATCH_PATH=$(realpath -m ${PATCH_PATH})
NAME=${PATCH_PATH##*/}
BASENAME=${NAME%%.*}
RELEASE=${NAME#*.}
RELEASE=${RELEASE%.*}
PATCH_RELEASE=$(helper::config::list_releases | grep v${RELEASE} | head -1)
PATCH_LIST=$(helper::config::get_patches_all ${PATCH_RELEASE})
BASE_RELEASE=$(helper::config::base_chain ${PATCH_RELEASE} | tail -1)
COMMIT_COUNT=$(cat ${PATCH_PATH} | grep 'Subject: \[PATCH' | wc -l | tr -d ' ')
${KITDIR}/git_fetch_tag.sh ${BASE_RELEASE}
PATCHES_LIST=$(helper::config::get_patch "${PATCH_LIST}")
for patch in ${PATCHES_LIST}; do
if [[ "${patch}" =~ "${PATCH_PATH}" ]]; then
break
fi
${KITDIR}/git_patch.sh "${patch}"
done
${KITDIR}/git_patch.sh "${PATCH_PATH}"
cd "${WORKDIR}" && git format-patch "-$COMMIT_COUNT" --abbrev=11 --zero-commit --no-signature --stdout >"${PATCH_PATH}"