diff --git a/buildlib/az-helpers.sh b/buildlib/az-helpers.sh index b3098edb138..814a516e05d 100644 --- a/buildlib/az-helpers.sh +++ b/buildlib/az-helpers.sh @@ -249,11 +249,12 @@ check_release_build() { elif [ "${build_reason}" == "PullRequest" ] then - # In case of pull request, HEAD^ is the branch commit we merge with - range="$(git rev-parse HEAD^)..${build_sourceversion}" - for sha1 in `git log $range --format="%h"` + base_revision=$(git rev-parse "${build_sourceversion}^1") + head_revision=$(git rev-parse "${build_sourceversion}^2") + for sha1 in $(git log --first-parent --no-merges \ + "${base_revision}..${head_revision}" --format="%h") do - title=`git log -1 --format="%s" $sha1` + title=$(git log -1 --format="%s" $sha1) [[ "$title" == "${title_mask}"* ]] && launch=True; done fi diff --git a/buildlib/pr/codestyle.yml b/buildlib/pr/codestyle.yml index 8295eea5dbb..f88b78aba67 100644 --- a/buildlib/pr/codestyle.yml +++ b/buildlib/pr/codestyle.yml @@ -18,10 +18,10 @@ jobs: set -eE source ./buildlib/tools/codestyle.sh - BASE_SOURCEVERSION=$(git rev-parse HEAD^) - range="$BASE_SOURCEVERSION..$(Build.SourceVersion)" + base_revision=$(git rev-parse "$(Build.SourceVersion)^1") + head_revision=$(git rev-parse "$(Build.SourceVersion)^2") - codestyle_check_commit_title "$range" + codestyle_check_commit_title "$base_revision..$head_revision" if [[ $? -ne 0 ]] then url="https://github.com/openucx/ucx/wiki/Guidance-for-contributors#general-guidelines" @@ -85,11 +85,10 @@ jobs: - bash: | set -eEx - BASE_SOURCEVERSION=$(git rev-parse HEAD^) - range="$BASE_SOURCEVERSION..$(Build.SourceVersion)" + base_revision=$(git rev-parse "$(Build.SourceVersion)^1") + head_revision=$(git rev-parse "$(Build.SourceVersion)^2") - echo "Looking for missing AUTHORS on commit range ${range}" - ./contrib/authors_update.sh "$range" + ./contrib/authors_update.sh "$base_revision..$head_revision" git diff --exit-code displayName: AUTHORS file check diff --git a/buildlib/tools/codestyle.sh b/buildlib/tools/codestyle.sh index e07573c48fd..4b0bd29238c 100644 --- a/buildlib/tools/codestyle.sh +++ b/buildlib/tools/codestyle.sh @@ -8,10 +8,10 @@ codestyle_check_commit_title() { local range="$1" local err=0 - for sha1 in `git log "$range" --format="%h"` + for sha1 in $(git log --first-parent --no-merges "$range" --format="%h") do - title=`git log -1 --format="%s" $sha1` - if echo $title | grep -qP '^Merge |^[0-9A-Z/_\-]*: \w' + title=$(git log -1 --format="%s" $sha1) + if [[ $title =~ ^[0-9A-Z/_-]*:\ [[:alnum:]_] ]] then echo "Good commit title: '$title'" else diff --git a/contrib/authors_update.sh b/contrib/authors_update.sh index a9e60a625c9..c25bc49f8a9 100755 --- a/contrib/authors_update.sh +++ b/contrib/authors_update.sh @@ -15,7 +15,8 @@ then fi # Failure message triggered if range is not valid -lines=$(git log --no-merges --pretty=format:"%an%x09%ae" "$range" | sort -u) +lines=$(git log --first-parent --no-merges --pretty=format:"%an%x09%ae" \ + "$range" | sort -u) if [ -z "$lines" ] then echo "Error: provided range \"$range\" is empty"