github.com/muhammadn/cortex@v1.9.1-0.20220510110439-46bb7000d03d/tools/release/check-changelog.sh (about)

     1  #!/bin/bash
     2  
     3  # Expect as input parameter the commits range to analyze.
     4  if [ $# -ne 1 ]; then
     5      echo "Usage: $0 range"
     6      echo ""
     7      echo "  range   The commit range to compare as documented at:"
     8      echo "          https://git-scm.com/docs/gitrevisions"
     9      echo ""
    10      echo "Example:"
    11      echo "  $0 v0.4.0...master"
    12      echo ""
    13      exit 1
    14  fi
    15  
    16  # Find all merged PRs.
    17  GIT_LOG=$(git log --pretty=format:"%s" $1)
    18  PR_LIST=$(echo "$GIT_LOG" | grep -Eo '#[0-9]+')
    19  PR_LIST_COUNT=$(echo "$PR_LIST" | wc -l | grep -Eo '[0-9]+')
    20  PR_AUTHORS_COUNT=$(git log --pretty=format:"%an" $1 | sort | uniq -i | wc -l | grep -Eo '[0-9]+')
    21  echo "Found ${PR_LIST_COUNT} PRs from ${PR_AUTHORS_COUNT} authors."
    22  echo ""
    23  
    24  # For each PR check if it's mentioned in the changelog.
    25  echo "List of missing PR in the CHANGELOG.md:"
    26  for PR in $PR_LIST; do
    27      grep -q "$PR" CHANGELOG.md
    28      if [ $? -eq 0 ]; then
    29          continue
    30      fi
    31  
    32      # Print 1 line for the missing PR
    33      echo -n "- ${PR}: "
    34      echo "$GIT_LOG" | grep "$PR"
    35  done