test-all-commits-compile.sh 917 B

12345678910111213141516171819202122232425262728293031323334353637
  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. BRANCH=$(git rev-parse --abbrev-ref HEAD)
  8. if [ "$BRANCH" = "master" ]; then
  9. echo "Don't run on master branch"
  10. exit 1
  11. fi
  12. COMMITS=$(git log --oneline --reverse master.. | cut -d " " -f 1)
  13. CODE=0
  14. for COMMIT in $COMMITS
  15. do
  16. git checkout $COMMIT
  17. # run-tests
  18. echo "------------------------------------------------------------"
  19. go install ./...
  20. if [ $? -eq 0 ]
  21. then
  22. echo $COMMIT - passed
  23. else
  24. echo $COMMIT - failed
  25. git checkout ${BRANCH}
  26. exit
  27. fi
  28. echo "------------------------------------------------------------"
  29. done
  30. git checkout ${BRANCH}
  31. echo "All OK"