try to use blob and commit for changed file

This commit is contained in:
Gerhard Hoffmann 2023-04-25 10:50:10 +02:00
parent 93ba8215b9
commit f248f3f85f

View File

@ -23,28 +23,34 @@ get_blob () { # get the blob of the file(name) passed as $1
}
get_commit_for_blob () {
blob=$(get_blob $1)
if [ ! -z $blob ]; then
if [ ! -z $1 ]; then
# search for the blob in all commits for the file(name) $1
echo $(echo $(git log --all --pretty=format:%H -- $1) |
xargs -I{} bash -c "git ls-tree {} -- $1 |
grep -q $blob && echo {}")
grep -q $1 && echo {}")
fi
}
changed_file_names () {
for fn in $(git diff-tree -r HEAD@{1} HEAD --name-only); do
# called in repository: $fn is e.g. etc/psa_tariff/tariff01.json
# add '/' prefix
fn=$(echo $fn | awk '{ printf "/"$0 }')
CHANGED_FILE_NAMES+=($fn)
done
}
for fn in $(git diff-tree -r HEAD@{1} HEAD --name-only); do
if grep -E -q "(DC.*json|dc.*hex|dc.*bin|tariff.*json)" <<< $fn; then
fsize=0
# called in repository: $fn is e.g. etc/psa_tariff/tariff01.json
# add '/' prefix
fn=$(echo $fn | awk '{ printf "/"$0 }')
if [[ -f "$fn" ]]; then
blob=$(get_blob "$fn")
commit=$(get_commit_for_blob $blob)
fsize=$(ls -l "$fn" | awk '{ print $5 }')
echo "$fn $fsize $blob $commit" >> $GIT_PULL_TMP
fi
echo "$fn $fsize" >> $GIT_PULL_TMP
fi
if grep -E -q ".*opkg_commands" <<< $fn; then
readarray opkg_commands < <(cat $fn)