Skip to content

Commit

Permalink
Fix script to verify docs changes (hashicorp#20317)
Browse files Browse the repository at this point in the history
Signed-off-by: Jaymala Sinha <jaymala@hashicorp.com>
  • Loading branch information
Jaymala committed Apr 24, 2023
1 parent 92fb1a3 commit 788f337
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions .github/scripts/verify_changes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@ if [[ "$event_type" == "pull_request" ]]; then
git fetch --no-tags --prune origin $head_ref
git fetch --no-tags --prune origin $base_ref
head_commit="origin/$head_ref"
prev_commit="origin/$base_ref"
base_commit="origin/$base_ref"
else
git fetch --no-tags --prune origin $ref_name
head_commit=$(git log origin/$ref_name --oneline | head -1 | awk '{print $1}')
prev_commit=$(git log origin/$ref_name --oneline | head -2 | awk 'NR==2 {print $1}')
base_commit=$(git log origin/$ref_name --oneline | head -2 | awk 'NR==2 {print $1}')
fi

change_count=$(git diff $head_commit..$prev_commit --name-only | awk -F"/" '{ print $1}' | uniq | wc -l)
# git diff with ... shows the differences count between base_commit and head_commit starting at the last common commit
change_count=$(git diff $base_commit...$head_commit --name-only | awk -F"/" '{ print $1}' | uniq | wc -l)

if [[ $change_count -eq 1 ]]; then
changed_dir=$(git diff $head_commit..$prev_commit --name-only | awk -F"/" '{ print $1}' | uniq)
changed_dir=$(git diff $base_commit...$head_commit --name-only | awk -F"/" '{ print $1}' | uniq)
fi

if [[ "$changed_dir" == "website" ]]; then
Expand Down

0 comments on commit 788f337

Please sign in to comment.