update_grandalf.sh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/bash
  2. # # delete stale grandalf
  3. # rm -rf ./grandalf
  4. # # oddly, github can convert to svn and then I can checkout the folder as an svn repo...?
  5. # # get it
  6. # svn checkout https://github.com/bdcht/grandalf/trunk/grandalf/
  7. # # delete the .svn stuff and the __pycache__ if they exist
  8. # rm -rf ./grandalf/.svn
  9. # github no longer supports this, darn
  10. #
  11. # https://www.educative.io/answers/how-to-download-a-single-folder-or-directory-from-a-github-repo
  12. #
  13. # i have already set it up for sparse checkout but it doesn't do exactly what I want so I have top fudge it
  14. # pass
  15. if [[ -d "./grandalf/__pycache__" ]]
  16. then
  17. rm -r ./grandalf/__pycache__
  18. fi
  19. if [[ -d "./grandalf/utils/__pycache__" ]]
  20. then
  21. rm -r ./grandalf/utils/__pycache__
  22. fi
  23. mkdir grandalf 2>/dev/null # we don't need the error message
  24. cd grandalf
  25. if [[ -d "./.git" ]]
  26. then
  27. echo 'skipping initialize grandalf because it already exists'
  28. rm -rf utils
  29. rm -rf *.py # danger here
  30. else
  31. git init
  32. git remote add origin https://github.com/bdcht/grandalf.git
  33. echo 'grandalf' > .git/info/sparse-checkout
  34. git config core.sparseCheckout true
  35. fi
  36. git restore *
  37. git pull origin master
  38. mv ./grandalf/* .
  39. rmdir grandalf
  40. rm ./utils/__init__.py
  41. rm __init__.py
  42. # there is probably a right way to do this but the extensions thing makes it really irritating
  43. # annoying
  44. # fix the imports, they need to be made relative to Mantis.
  45. sed -i 's/grandalf\.utils/.utils/g' ./*.py # annoyingly, it isn't consistent in the repo
  46. # sed -i 's/\.utils/.grandalf.utils/g' ./*.py
  47. # no idea why anything this stupid and bad and dumb is necessary
  48. sed -i 's/from \.utils import Poset/from \.utils.poset import Poset/g' ./*.py
  49. # this works
  50. cd ..