generate_gitignore.sh 711 B

12345678910111213141516171819202122232425
  1. #!/usr/bin/env bash
  2. set -e
  3. echo "# This file was generated automatically by running build/git/generate_gitignore.sh inside a svn working copy." > .gitignore
  4. (
  5. svn pl --recursive --xml | xpath -q -e '/properties/target[property/@name = "svn:ignore"]' | grep '^<target' | sed 's/<target path=//g' | sed 's/>$//g' | sed 's/"//g'
  6. ) | sort | while IFS=$'\n' read -r WCDIR ; do
  7. if [ "x$WCDIR" = "x." ] ; then
  8. PREFIX="/"
  9. else
  10. PREFIX="/${WCDIR}/"
  11. fi
  12. echo "checking ${WCDIR} ..."
  13. (
  14. svn pg svn:ignore "${WCDIR}"
  15. ) | sort | while IFS=$'\n' read -r PATTERN ; do
  16. if [ "x$PATTERN" != "x" ] ; then
  17. echo " setting ${WCDIR}: ${PREFIX}${PATTERN}"
  18. echo "${PREFIX}${PATTERN}" >> .gitignore
  19. fi
  20. done
  21. done