Build contexts should not include .repo/repo

Build avoidance does not work reliably because directory
.repo/repo is being included in the build context.
This directory is the repo tool itself, not any of the
gits managed by the repo manifest.  The sha reported for
.repo/repo might not be available in users environmnet,
causing build avoidance to reject an otherwise valid
reference context.

Fix is in two parts.
1) Do not include .repo/repo in future build contexts.
2) Filter .repo/repo out of downloaded contexts before
use in build avoidance calculations.  This addresses
contexts that are already published.

Closes-Bug: 1893243
Change-Id: I7bd20597cb7bc5ee93ae49728176791c51e89c53
Signed-off-by: Scott Little <scott.little@windriver.com>
This commit is contained in:
Scott Little 2020-08-27 14:21:47 -04:00
parent b5bc6fe8dc
commit 2dd5d9f07c
1 changed files with 5 additions and 4 deletions

View File

@ -27,7 +27,7 @@ git_ctx_root_dir () {
git_list () {
local DIR=${1}
find -L "${DIR}" -maxdepth 5 -type d -name '.git' -exec dirname {} \; | sort -V
find -L "${DIR}" -maxdepth 5 -type d -name '.git' -exec dirname {} \; | grep -v '[.]repo[/]repo$' | sort -V
}
@ -380,11 +380,12 @@ git_test_context () {
# Limit search to last 500 commits in the interest of speed.
# I don't expect to be using contexts more than a few weeks old.
cat "$context" | \
sed "s#checkout -f \([a-e0-9]*\)#rev-list --max-count=500 HEAD | \
sed -e "s/\.repo\/repo/d" \
-e "s#checkout -f \([a-e0-9]*\)#rev-list --max-count=500 HEAD | \
grep \1#" > $query
target_hits=$(cat "$context" | wc -l)
actual_hits=$(cd $(git_ctx_root_dir); source $query | wc -l)
target_hits=$(cat "$context" | grep -v '[.]repo[/]repo ' | wc -l)
actual_hits=$(cd $(git_ctx_root_dir); source $query 2> /dev/null | wc -l)
\rm $query
if [ $actual_hits -eq $target_hits ]; then