Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

demoscript 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. scriptloc=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)
  4. replace() {
  5. keyword=$1
  6. string=$2
  7. python << END
  8. with open("${scriptloc}/slides.md") as slides:
  9. content = slides.read()
  10. string = """${string}"""
  11. with open("${scriptloc}/slides.md", "w") as slides:
  12. slides.write(content.replace(r"${keyword}", string))
  13. END
  14. }
  15. mdprint() {
  16. cmd=$*
  17. echo '```bash'
  18. echo '$' ${cmd}
  19. eval ${cmd}
  20. echo '```'
  21. }
  22. tmpdir=$(mktemp -d)
  23. pushd ${tmpdir}
  24. # delete temporary directory on script exit
  25. trap "rm -fr ${tmpdir}" 0
  26. # Initialise repository
  27. mdprint git init
  28. git config --local user.name "Achilleas Koutsou"
  29. git config --local user.email "ak@example.com"
  30. # No objects here yet
  31. mdprint tree -F .git/objects
  32. # Add a README and commit
  33. mdprint 'echo "# Understanding Git: Presentation slides repository" > README.md'
  34. mdprint git add README.md
  35. firstcommit=$(mdprint 'git commit -m "Initial commit: Add README"')
  36. replace "::firstcommit::" "${firstcommit}"
  37. # Check the object store again
  38. firstobjectstore=$(mdprint tree -F .git/objects)
  39. replace "::firstobjectstore::" "${firstobjectstore}"
  40. filepaths1=$(find .git/objects -type f)
  41. # git cat-file on each object
  42. for path in ${filepaths1}; do
  43. prefix=${path:13:2}
  44. rest=${path:16}
  45. full=${prefix}${rest}
  46. type=$(git cat-file -t ${full})
  47. cattype=$(mdprint git cat-file -t ${full})
  48. catprint=$(mdprint git cat-file -p ${full})
  49. replace "::catt${type}1::" "${cattype}"
  50. replace "::catp${type}1::" "${catprint}"
  51. done
  52. # Let's make one more commit so we can see the parent
  53. mdprint 'echo -e "# Understanding Git\n\n> Achilleas Koutsou\n\n2018-11-14" > slides.md'
  54. mdprint git add slides.md
  55. mdprint 'git commit -m "Add first presentation slide"'
  56. # Check the object store again
  57. mdprint tree -F .git/objects
  58. secondobjectstore=$(mdprint find .git/objects -type f)
  59. replace "::secondobjectstore::" "${secondobjectstore}"
  60. filepaths2=$(find .git/objects -type f)
  61. # git cat-file on each *new* object
  62. for path in ${filepaths2}; do
  63. if echo ${filepaths1} | grep ${path} &> /dev/null; then
  64. continue
  65. fi
  66. prefix=${path:13:2}
  67. rest=${path:16}
  68. full=${prefix}${rest}
  69. mdprint git cat-file -t ${full}
  70. mdprint git cat-file -p ${full}
  71. type=$(git cat-file -t ${full})
  72. cattype=$(mdprint git cat-file -t ${full})
  73. catprint=$(mdprint git cat-file -p ${full})
  74. replace "::catt${type}2::" "${cattype}"
  75. replace "::catp${type}2::" "${catprint}"
  76. if git cat-file -p ${full} | grep "Understanding Git" &> /dev/null; then
  77. slidesfirstver=${full}
  78. fi
  79. done
  80. echo "--------------------------"
  81. # Add a new slide
  82. mdprint 'echo -e "\n\n# Part 1\n## Porcelain and Plumbing" >> slides.md'
  83. mdprint git add slides.md
  84. mdprint 'git commit -m "Add second presentation slide"'
  85. # Check the object store again
  86. thirdobjectstore=$(mdprint find .git/objects -type f)
  87. replace "::thirdobjectstore::" "${thirdobjectstore}"
  88. filepaths3=$(find .git/objects -type f)
  89. # git cat-file on each *new* object
  90. for path in ${filepaths3}; do
  91. if echo ${filepaths2} | grep ${path} &> /dev/null; then
  92. continue
  93. fi
  94. prefix=${path:13:2}
  95. rest=${path:16}
  96. full=${prefix}${rest}
  97. mdprint git cat-file -t ${full}
  98. mdprint git cat-file -p ${full}
  99. type=$(git cat-file -t ${full})
  100. cattype=$(mdprint git cat-file -t ${full})
  101. catprint=$(mdprint git cat-file -p ${full})
  102. replace "::catt${type}3::" "${cattype}"
  103. replace "::catp${type}3::" "${catprint}"
  104. done
  105. mdprint git cat-file -p ${slidesfirstver}
  106. mdprint git cat-file -t HEAD
  107. mdprint git cat-file -t master
  108. catpmaster=$(mdprint git cat-file -p master)
  109. replace "::catpmaster::" "${catpmaster}"
  110. mdprint git cat-file -t master~1
  111. mdprint git cat-file -t master~1:
  112. mdprint git cat-file -p master~1:slides.md
  113. mdprint git cat-file -p master~1:README.md
  114. mdprint git cat-file -p master:README.md
  115. rpheada=$(mdprint git rev-parse HEAD)
  116. replace "::rpheada::" "${rpheada}"
  117. rpmastera=$(mdprint git rev-parse master)
  118. replace "::rpmastera::" "${rpmastera}"
  119. catpheada=$(mdprint git cat-file -p HEAD)
  120. replace "::catpheada::" "${catpheada}"
  121. rpheadtld1a=$(mdprint git rev-parse HEAD~1)
  122. replace "::rpheadtld1a::" "${rpheadtld1a}"
  123. catpmastertld1clna=$(mdprint git cat-file -p master~1:)
  124. replace "::catpmastertld1clna::" "${catpmastertld1clna}"
  125. catpmastertld1rdma=$(mdprint git rev-parse master~1:README.md)
  126. replace "::catpmastertld1rdma::" "${catpmastertld1rdma}"
  127. mdprint git branch demo-code
  128. rpmasterdemohead=$(mdprint git rev-parse master demo-code HEAD)
  129. replace "::rpmasterdemohead::" "${rpmasterdemohead}"
  130. mdprint git checkout demo-code
  131. mdprint 'echo "#!/usr/bin/env bash" > demoscript'
  132. mdprint 'chmod +x demoscript'
  133. mdprint 'git add demoscript'
  134. mdprint 'git commit -m "Add demoscript"'
  135. rpmasterb=$(mdprint git rev-parse master)
  136. replace "::rpmasterb::" "${rpmasterb}"
  137. rpdemob=$(mdprint git rev-parse demo-code)
  138. replace "::rpdemob::" "${rpdemob}"
  139. rpheadb=$(mdprint git rev-parse HEAD)
  140. replace "::rpheadb::" "${rpheadb}"
  141. mdprint git checkout master
  142. rpmasterc=$(mdprint git rev-parse master)
  143. replace "::rpmasterc::" "${rpmasterc}"
  144. rpdemoc=$(mdprint git rev-parse demo-code)
  145. replace "::rpdemoc::" "${rpdemoc}"
  146. rpheadc=$(mdprint git rev-parse HEAD)
  147. replace "::rpheadc::" "${rpheadc}"
  148. mdprint ls
  149. mdprint 'echo -e "\n\n# Part 2\n## What is Git?" >> slides.md'
  150. mdprint git add slides.md
  151. mdprint 'git commit -m "Add third presentation slide"'
  152. rpmasterdemod=$(mdprint git rev-parse master~1 demo-code~1)
  153. replace "::rpmasterdemod::" "${rpmasterdemod}"
  154. gitloga=$(mdprint git log -n 2)
  155. replace "::gitloga::" "${gitloga}"
  156. gitlogb=$(mdprint 'git log --pretty=format:"Commit: %h | Parent: %p | Tree: %t %n Message: %s%n"')
  157. replace "::gitlogb::" "${gitlogb}"
  158. gitlogc=$(mdprint 'git log --graph --oneline master demo-code')
  159. replace "::gitlogc::" "${gitlogc}"
  160. git checkout demo-code
  161. echo "<code line 1>" >> demoscript
  162. git commit demoscript -m "Writing script"
  163. echo "<code line 2>" >> demoscript
  164. git commit demoscript -m "Finalising script"
  165. gitlogd=$(mdprint 'git log --graph --decorate --oneline master demo-code')
  166. replace "::gitlogd::" "${gitlogd}"
  167. export GIT_MERGE_AUTOEDIT=no
  168. mdprint git checkout master
  169. gitmergea=$(mdprint git merge demo-code)
  170. replace "::gitmergea::" "${gitmergea}"
  171. gitloge=$(mdprint 'git log --graph --decorate --oneline master demo-code')
  172. replace "::gitloge::" "${gitloge}"
  173. gitlogf=$(mdprint 'git log --oneline master')
  174. replace "::gitlogf::" "${gitlogf}"
  175. gitcatpheadtld1b=$(mdprint 'git cat-file -p HEAD~1')
  176. replace "::gitcatpheadtld1b::" "${gitcatpheadtld1b}"
  177. gitcatpheadtldcln1b=$(mdprint 'git cat-file -p HEAD~1:')
  178. replace "::gitcatpheadtld1clnb::" "${gitcatpheadtldcln1b}"
  179. gitcatpmerge=$(mdprint 'git cat-file -p HEAD')
  180. replace "::gitcatpmerge::" "${gitcatpmerge}"
  181. gitbranchf=$(mdprint git branch)
  182. replace "::gitbranchf::" "${gitbranchf}"
  183. gitlogall=$(mdprint git log --all --graph)
  184. replace "::gitlogall::" "${gitlogall}"
  185. appendreadme=$(mdprint 'echo "See slides.md for slides" >> README.md')
  186. replace "::appendreadme::" "${appendreadme}"
  187. gitstatusf=$(mdprint git status)
  188. replace "::gitstatusf::" "${gitstatusf}"
  189. gitdiff=$(mdprint git diff)
  190. replace "::gitdiff::" "${gitdiff}"
  191. gitdiffdemo=$(mdprint git diff demo-code)
  192. replace "::gitdiffdemo::" "${gitdiffdemo}"
  193. git commit README.md -m "Mention slides in README"
  194. gitcatsrdma=$(mdprint git cat-file -s HEAD:README.md)
  195. replace "::gitcatsrdma::" "${gitcatsrdma}"
  196. gitcatprdma=$(mdprint git cat-file -p HEAD:README.md)
  197. replace "::gitcatprdma::" "${gitcatprdma}"
  198. gitcatsrdmb=$(mdprint git cat-file -s HEAD~1:README.md)
  199. replace "::gitcatsrdmb::" "${gitcatsrdmb}"
  200. gitcatprdmb=$(mdprint git cat-file -p HEAD~1:README.md)
  201. replace "::gitcatprdmb::" "${gitcatprdmb}"
  202. ospregc=$(mdprint find .git/objects -type f)
  203. replace "::ospregc::" "${ospregc}"
  204. osdupre=$(mdprint du -s .git/objects)
  205. replace "::osdupre::" "${osdupre}"
  206. gitgc=$(mdprint git gc)
  207. replace "::gitgc::" "${gitgc}"
  208. ospostgc=$(mdprint find .git/objects -type f)
  209. replace "::ospostgc::" "${ospostgc}"
  210. osdupost=$(mdprint du -s .git/objects)
  211. replace "::osdupost::" "${osdupost}"
  212. apack=$(find .git/objects -type f -iname "*.pack" | head -n1)
  213. verifypack=$(mdprint git verify-pack -v ${apack})
  214. replace "::verifypack::" "${verifypack}"
  215. exit
  216. # ---------------
  217. mdprint git log --graph master demo-code
  218. mdprint 'git log --graph --pretty=format:"Commit: %H%n Message: %s%n Parent: %P%n Tree: %T%n%n" master demo-code'
  219. git log --reverse --pretty=format:"Commit: %H%n Message: %s%n Parent: %P%n Tree: %T%n%n"