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

     1  #!/bin/bash
     2  
     3  if [ "$#" -ne 1 ]; then
     4      echo "Usage: ./scripts/cherry_pick/cherry_pick.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  echo "Cherry-picking changes..."
    16  git cherry-pick --no-commit --mainline 1 "$COMMIT_ID"
    17  
    18  echo "Unstaging files removed by us..."
    19  git status --short | sed -n 's/^DU //p' | ifne xargs git rm
    20  
    21  echo "Unstaging added files that match the ignore list..."
    22  git status --short | sed -n 's/^A  //p' | grep -Ef ./scripts/cherry_pick/IGNORE_FILES | ifne xargs git rm -f
    23  
    24  echo "Unstaging files where SDK intentionally diverges from Core..."
    25  for f in $(git diff --name-only --cached | grep -Ef ./scripts/cherry_pick/IGNORE_FILES)
    26  do
    27      git reset "$f"
    28      git checkout -- "$f"
    29  done
    30  
    31  echo "Committing changes. If this fails, you must resolve the merge conflict manually."
    32  ./scripts/cherry_pick/commit.sh $COMMIT_ID && echo "Success!"