github.com/10XDev/rclone@v1.52.3-0.20200626220027-16af9ab76b2a/bin/test-all-commits-compile.sh (about)

     1  #!/bin/sh
     2  # This tests rclone compiles for all the commits in the branch
     3  #
     4  # It assumes that the branch is rebased onto master and checks all the commits from branch root to master
     5  #
     6  # Adapted from: https://blog.ploeh.dk/2013/10/07/verifying-every-single-commit-in-a-git-branch/
     7  
     8  BRANCH=$(git rev-parse --abbrev-ref HEAD)
     9  if [ "$BRANCH" = "master" ]; then
    10      echo "Don't run on master branch"
    11      exit 1
    12  fi
    13  COMMITS=$(git log --oneline --reverse master.. | cut -d " " -f 1)
    14  CODE=0
    15  
    16  for COMMIT in $COMMITS
    17  do
    18      git checkout $COMMIT
    19      
    20      # run-tests
    21      echo "------------------------------------------------------------"
    22      go install ./...
    23      
    24      if [ $? -eq 0 ]
    25      then
    26          echo $COMMIT - passed
    27      else
    28          echo $COMMIT - failed
    29          git checkout ${BRANCH}
    30          exit
    31      fi
    32      echo "------------------------------------------------------------"
    33  done
    34   
    35  git checkout ${BRANCH}
    36  echo "All OK"