summaryrefslogtreecommitdiff
path: root/ikiwiki-makerepo
blob: a6999cb4a32288ef53910c664921661d981306d8 (plain)
  1. #!/bin/sh
  2. set -e
  3. rcs="$1"
  4. srcdir="$2"
  5. repository="$3"
  6. usage () {
  7. echo "usage: ikiwiki-makerepo svn|git srcdir repository" >&2
  8. echo " ikiwiki-makerepo mercurial srcdir" >&2
  9. exit 1
  10. }
  11. if [ -z "$rcs" ] || [ -z "$srcdir" ]; then
  12. usage
  13. fi
  14. if [ ! -d "$srcdir" ]; then
  15. echo "srcdir $srcdir not found" >&2
  16. exit 1
  17. fi
  18. if [ "$rcs" != mercurial ]; then
  19. if [ -e "$repository" ]; then
  20. echo "repository $repository already exists, aborting" >&2
  21. exit 1
  22. fi
  23. repository="$(perl -e 'use Cwd q{abs_path}; print abs_path(shift)' $repository)"
  24. if [ -z "$repository" ]; then
  25. echo "internal error finding repository abs_path" >&2
  26. exit 1
  27. fi
  28. fi
  29. echo "Importing $srcdir into $rcs"
  30. case "$rcs" in
  31. svn)
  32. if [ -e "$srcdir/.svn" ]; then
  33. echo "$srcdir already seems to be a svn working copy" >&2
  34. exit 1
  35. fi
  36. svnadmin create "$repository"
  37. svn mkdir "file://$repository/trunk" -m "create trunk directory"
  38. cd "$srcdir"
  39. svn co "file://$repository/trunk" .
  40. svn propset svn:ignore ".ikiwiki" .
  41. svn add *
  42. svn commit -m "initial import"
  43. echo "Directory $srcdir is now a checkout of $rcs repository $repository"
  44. ;;
  45. git)
  46. GIT_DIR="$repository" git --bare init --shared
  47. cd "$srcdir"
  48. git init
  49. echo /.ikiwiki > .gitignore
  50. git add .
  51. git commit -m "initial commit"
  52. git remote add origin "$repository"
  53. git config branch.master.merge refs/heads/master
  54. git push --all
  55. echo "Directory $srcdir is now a clone of $rcs repository $repository"
  56. ;;
  57. mercurial)
  58. hg init "$srcdir"
  59. cd "$srcdir"
  60. echo .ikiwiki > .hgignore
  61. hg add * .hgignore
  62. hg commit -m "initial import"
  63. echo "Directory $srcdir is now set up as a mercurial repository"
  64. ;;
  65. *)
  66. echo "Unsupported revision control system $rcs" >&2
  67. usage
  68. ;;
  69. esac