github.com/hashicorp/terraform-plugin-sdk@v1.17.2/scripts/cherry_pick/commit.sh (about)

     1  #!/bin/bash
     2  
     3  if [ "$#" -ne 1 ]; then
     4      echo "Usage: ./scripts/cherry_pick/commit.sh MERGE_COMMIT_HASH"
     5  fi
     6  
     7  function pleaseUseGNUsed {
     8      echo "Please install GNU sed to your PATH as 'sed'."
     9      exit 1
    10  }
    11  sed --version > /dev/null || pleaseUseGNUsed
    12  
    13  COMMIT_ID=$1
    14  
    15  COMMIT_MSG=$(git log --format=%B -n 1 "$COMMIT_ID" | \
    16                   sed -z -r 's/Merge pull request (#[0-9]+) from ([^\n]*\/[^\n]*)\n\n(.*$)/\3\nThis commit was generated from hashicorp\/terraform\1./g')
    17  
    18  git commit -C "$COMMIT_ID" && \
    19      # amend commit message afterwards to preserve authorship information
    20      git commit --amend --message "${COMMIT_MSG}"