pr-urls.sh 901 B

1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/env bash
  2. set -Eeuo pipefail
  3. #
  4. # usage:
  5. # $ ./pr-urls.sh PR-NUMBER
  6. # $ ./pr-urls.sh PR-NUMBER IMAGE1 IMAGE2:TAG1 IMAGE3:TAG2
  7. #
  8. # $ ./pr-urls.sh 12072
  9. # $ ./pr-urls.sh 12072 hello-world:linux
  10. # $ ./pr-urls.sh 12072 | xargs -rt bashbrew build
  11. # $ ./pr-urls.sh 12072 | xargs -rt bashbrew list --uniq
  12. # $ ./pr-urls.sh 12072 | xargs -rt bashbrew list --uniq | xargs -rt ./test/run.sh
  13. #
  14. # (rough replacement for the old "test-pr.sh" script and its associated complexity)
  15. #
  16. pr="$1"
  17. shift
  18. patch="$(wget -qO- "https://github.com/docker-library/official-images/pull/$pr.patch")"
  19. commit="$(grep <<<"$patch" -oE '^From [0-9a-f]+ ' | tail -1 | cut -d' ' -f2)"
  20. if [ "$#" -eq 0 ]; then
  21. files="$(grep <<<"$patch" -oE '^[+]{3} b/library/.+' | cut -d/ -f3 | sort -u)"
  22. set -- $files
  23. fi
  24. for file; do
  25. echo "https://github.com/docker-library/official-images/raw/$commit/library/$file"
  26. done