@@ -24,24 +24,36 @@ resolved_miss_map=$(
2424 change_commit=$( git --no-pager blame -L" $line " ,+1 -- " $chart /Chart.yaml" | awk ' {print $1}' )
2525
2626 if [ " $change_commit " = " 00000000" ]; then
27- # Not commited yet, use previus commit
27+ # Not committed yet, use previous commit
2828 line=$( git show HEAD:" ./$chart /Chart.yaml" | awk ' /^version:/ {print NR; exit}' )
2929 commit=$( git --no-pager blame -L" $line " ,+1 HEAD -- " $chart /Chart.yaml" | awk ' {print $1}' )
3030 if [ $( echo $commit | cut -c1) = " ^" ]; then
31- # Previus commit not exists
31+ # Previous commit not exists
3232 commit=$( echo $commit | cut -c2-)
3333 fi
3434 else
35- # Commited , but version_map wasn't updated
35+ # Committed , but version_map wasn't updated
3636 line=$( git show HEAD:" ./$chart /Chart.yaml" | awk ' /^version:/ {print NR; exit}' )
3737 change_commit=$( git --no-pager blame -L" $line " ,+1 HEAD -- " $chart /Chart.yaml" | awk ' {print $1}' )
3838 if [ $( echo $change_commit | cut -c1) = " ^" ]; then
39- # Previus commit not exists
39+ # Previous commit not exists
4040 commit=$( echo $change_commit | cut -c2-)
4141 else
4242 commit=$( git describe --always " $change_commit ~1" )
4343 fi
4444 fi
45+
46+ # Check if the commit belongs to the main branch
47+ if ! git merge-base --is-ancestor " $commit " main; then
48+ # Find the closest parent commit that belongs to main
49+ commit_in_main=$( git log --pretty=format:" %H" main -- " $chart /Chart.yaml" | head -n 1)
50+ if [ -n " $commit_in_main " ]; then
51+ commit=" $commit_in_main "
52+ else
53+ # No valid commit found in main branch for $chart, skipping..."
54+ continue
55+ fi
56+ fi
4557 fi
4658 echo " $chart $version $commit "
4759 done
0 commit comments