mirror of
https://github.com/netdata/libbpf.git
synced 2026-04-05 08:09:07 +08:00
sync: improve and automate already synced patches detection
Make detection more precise and automate skip/sync decision, if everything looks sane. Signed-off-by: Andrii Nakryiko <andriin@fb.com>
This commit is contained in:
committed by
Andrii Nakryiko
parent
11052fc1be
commit
715a58d593
@@ -56,14 +56,30 @@ commit_desc()
|
|||||||
git log -n1 --pretty='%h ("%s")' $1
|
git log -n1 --pretty='%h ("%s")' $1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Create commit single-line signature, which consists of:
|
||||||
|
# - full commit hash
|
||||||
|
# - author date in ISO8601 format
|
||||||
|
# - full commit body with newlines replaced with vertical bars (|)
|
||||||
|
# - shortstat appended at the end
|
||||||
|
# The idea is that this single-line signature is good enough to make final
|
||||||
|
# decision about whether two commits are the same, across different repos.
|
||||||
|
# $1 - commit ref
|
||||||
|
commit_signature()
|
||||||
|
{
|
||||||
|
git log -n1 --pretty='("%s")|%aI|%b' --shortstat $1 | tr '\n' '|'
|
||||||
|
}
|
||||||
|
|
||||||
TMP_DIR=$(mktemp -d)
|
TMP_DIR=$(mktemp -d)
|
||||||
|
|
||||||
cd_to ${LIBBPF_REPO}
|
cd_to ${LIBBPF_REPO}
|
||||||
|
|
||||||
SUFFIX=$(date --utc +%Y-%m-%dT%H-%M-%S.%3NZ)
|
SUFFIX=$(date --utc +%Y-%m-%dT%H-%M-%S.%3NZ)
|
||||||
BASELINE_COMMIT=${3-$(cat CHECKPOINT-COMMIT)}
|
BASELINE_COMMIT=${3-$(cat CHECKPOINT-COMMIT)}
|
||||||
|
|
||||||
echo "Dumping existing libbpf commit signatures..."
|
echo "Dumping existing libbpf commit signatures..."
|
||||||
git log --oneline -n500 > ${TMP_DIR}/libbpf_commits.txt
|
for h in $(git log --pretty='%h' -n500); do
|
||||||
|
echo $h "$(commit_signature $h)" >> ${TMP_DIR}/libbpf_commits.txt
|
||||||
|
done
|
||||||
|
|
||||||
# Use current kernel repo HEAD as a source of patches
|
# Use current kernel repo HEAD as a source of patches
|
||||||
cd_to ${LINUX_REPO}
|
cd_to ${LINUX_REPO}
|
||||||
@@ -118,12 +134,19 @@ LIBBPF_NEW_COMMITS=$(git rev-list --no-merges --topo-order --reverse ${BASELINE_
|
|||||||
for LIBBPF_NEW_COMMIT in ${LIBBPF_NEW_COMMITS}; do
|
for LIBBPF_NEW_COMMIT in ${LIBBPF_NEW_COMMITS}; do
|
||||||
COMMIT_DESC="$(commit_desc ${LIBBPF_NEW_COMMIT})"
|
COMMIT_DESC="$(commit_desc ${LIBBPF_NEW_COMMIT})"
|
||||||
echo "Checking '${COMMIT_DESC}'..."
|
echo "Checking '${COMMIT_DESC}'..."
|
||||||
SYNCED_COMMITS=$(grep -F "$(git log -n1 --pretty=format:%s ${LIBBPF_NEW_COMMIT})" ${TMP_DIR}/libbpf_commits.txt || echo "")
|
SYNCED_COMMIT_CNT=$(grep -F "$(commit_signature ${LIBBPF_NEW_COMMIT})" ${TMP_DIR}/libbpf_commits.txt | wc -l)
|
||||||
if [ -n "${SYNCED_COMMITS}" ]; then
|
if ((${SYNCED_COMMIT_CNT} > 0)); then
|
||||||
# commit with the same subject is already in libbpf, but it's not 100% the same commit, so check with user
|
# commit with the same subject is already in libbpf, but it's
|
||||||
echo "Commit '$(git log -n1 --oneline ${LIBBPF_NEW_COMMIT})' appears to be already synced into libbpf..."
|
# not 100% the same commit, so check with user
|
||||||
echo "Corresponding libbpf commit(s):"
|
echo "Commit '${COMMIT_DESC}' is synced into libbpf as:"
|
||||||
echo "${SYNCED_COMMITS}"
|
grep -F "$(commit_signature ${LIBBPF_NEW_COMMIT})" \
|
||||||
|
${TMP_DIR}/libbpf_commits.txt | \
|
||||||
|
cut -d'|' -f1 | sed -e 's/^/- /'
|
||||||
|
if ((${SYNCED_COMMIT_CNT} == 1)); then
|
||||||
|
echo "Skipping '${COMMIT_DESC}' due to unique match..."
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
echo "'${COMMIT_DESC} matches multiple commits, please, double-check!"
|
||||||
read -p "Do you want to skip it? [y/N]: " SHOULD_SKIP
|
read -p "Do you want to skip it? [y/N]: " SHOULD_SKIP
|
||||||
case "${SHOULD_SKIP}" in
|
case "${SHOULD_SKIP}" in
|
||||||
"y" | "Y")
|
"y" | "Y")
|
||||||
|
|||||||
Reference in New Issue
Block a user