GitRoot
Craft your forge, Build your project, Grow your community freely
1#!/usr/bin/env bash
2
3# SPDX-FileCopyrightText: 2025 Romain Maneschi <romain@gitroot.dev>
4#
5# SPDX-License-Identifier: EUPL-1.2
6
7trap 'catch $LINENO' ERR
8
9MY_LOG=${MY_LOG:-"/tmp/mylog.txt"}
10EXPECTED_ERROR=0
11
12catch() {
13 if [[ $EXPECTED_ERROR == 0 ]]; then
14 echo "🛑 unexpected error line $1"
15 exit 1
16 fi
17 report "🟢 expected err line $1"
18}
19
20mySleep() {
21 echo "🕐 wait $1"
22 echo "🕐 $1" >> $MY_LOG
23 sleep $1
24}
25
26function wait_for() {
27 start=`date +%s`
28 timeout=100
29 until [ $timeout -le 0 ] || (grep -q $1 $2 &> /dev/null); do
30 sleep 0.1
31 timeout=$(( timeout - 1 ))
32 done
33 if [ $timeout -le 0 ]; then
34 return 1
35 fi
36 end=`date +%s`
37 echo "🕐 $@ in `expr $end - $start` seconds"
38}
39
40function wait_ls() {
41 local start=$(date +%s)
42 local timeout=500
43 local target="$1"
44
45 until [ $timeout -le 0 ]; do
46 count=$(find "$target" -maxdepth 1 -mindepth 1 2>/dev/null | wc -l)
47 if [ "$count" -eq 3 ]; then
48 break
49 fi
50 sleep 0.1
51 ((timeout--))
52 done
53 if [ $timeout -le 0 ]; then
54 return 1
55 fi
56 local end=`date +%s`
57 echo "🕐 $@ in `expr $end - $start` seconds"
58 mySleep 0.3
59}
60
61function init_local_git() {
62 git config commit.gpgSign true
63 git config gpg.format ssh
64 git config user.signingkey $3
65 git config core.sshCommand "ssh -i ${4} -o IdentitiesOnly=yes"
66 git config user.email "$1"
67 git config user.name "$2"
68 git config gpg.ssh.allowedSignersFile "$(pwd)/.gitroot/allowed_signers"
69 echo "$1 $(cat $3)" >> "$(pwd)/.gitroot/allowed_signers"
70}
71
72EXIT_CODE=0
73
74SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
75
76source "${SCRIPT_DIR}/lib/pushandwait.sh"
77source "${SCRIPT_DIR}/lib/git.sh"
78source "${SCRIPT_DIR}/lib/report.sh"
79
80SERVER_PORT=${SERVER_PORT:-4545}
81SERVER_PORT_HTTP=${SERVER_PORT_HTTP:-4546}
82SERVER_URL=${1:-"127.0.0.1:$SERVER_PORT"}
83SERVER_DATA_DIR="/tmp/gitrootData"
84
85ROOT_REPO_NAME="root"
86ROOT_REPO_URL="ssh://${SERVER_URL}/${ROOT_REPO_NAME}"
87REPO1_NAME="repo1"
88REPO1_URL="ssh://user@${SERVER_URL}/${REPO1_NAME}"
89REPO2_NAME="repo2"
90REPO2_URL="ssh://user@${SERVER_URL}/${REPO2_NAME}"
91REPO3_NAME="repo3"
92REPO3_URL="ssh://user@${SERVER_URL}/${REPO3_NAME}"
93
94SSH_KEY="${SCRIPT_DIR}/user1/ed25519"
95SSH_KEY2="${SCRIPT_DIR}/user2/ed25519"
96SSH_KEY3="${SCRIPT_DIR}/user3/ed25519"
97
98LADYBUG_WASM="pkg://gitroot/gitroot/ladybug@0.0.5?registry=file://${SCRIPT_DIR}/../plugins/ladybug&checksum=none"
99SILO_WASM="pkg://gitroot/gitroot/silo@0.0.5?registry=file://${SCRIPT_DIR}/../plugins/silo&checksum=none"
100GRAFTER_WASM="pkg://gitroot/gitroot/grafter@0.0.5?registry=file://${SCRIPT_DIR}/../plugins/grafter&checksum=none"
101APEX_WASM="pkg://gitroot/gitroot/apex@0.0.5?registry=file://${SCRIPT_DIR}/../plugins/apex&checksum=none"
102APEX_MARKDOWN_WASM="pkg://gitroot/gitroot/apex_markdown@0.0.5?registry=file://${SCRIPT_DIR}/../plugins/apex&checksum=none"
103APEX_CODE_WASM="pkg://gitroot/gitroot/apex_code@0.0.5?registry=file://${SCRIPT_DIR}/../plugins/apex&checksum=none"
104APEX_CODE_MERMAID_WASM="pkg://gitroot/gitroot/apex_mermaid@0.0.2?registry=file://${SCRIPT_DIR}/../plugins/apex_mermaid&checksum=none"
105POLLEN_WASM="pkg://gitroot/gitroot/pollen@0.0.4?registry=file://${SCRIPT_DIR}/../plugins/pollen&checksum=none"
106HOP_WASM="pkg://gitroot/gitroot/hop@0.0.3?registry=file://${SCRIPT_DIR}/../plugins/hop&checksum=none"
107STIGMA_WASM="pkg://gitroot/gitroot/stigma@0.0.2?registry=file://${SCRIPT_DIR}/../plugins/stigma&checksum=none"
108FIREFLY_WASM="pkg://gitroot/gitroot/firefly@0.0.1?registry=file://${SCRIPT_DIR}/../plugins/firefly&checksum=none"
109
110##### clean
111report "🏁 clean"
112
113cd /tmp
114rm -rf ${SERVER_DATA_DIR}
115rm -rf ${ROOT_REPO_NAME}
116rm -rf ${ROOT_REPO_NAME}_2
117rm -rf ${REPO1_NAME}
118rm -rf ${REPO2_NAME}
119rm -rf ${REPO1_NAME}_2
120rm -rf ${REPO1_NAME}_3
121rm -rf ${REPO2_NAME}_2
122rm -rf ${REPO3_NAME}
123rm -f ${MY_LOG}
124APP=$(lsof -i tcp:${SERVER_PORT} | awk 'NR!=1 {print $2}')
125if [ -z "$APP" ]; then
126 report "🟢 Gitroot not launched"
127else
128 kill ${APP}
129 report "🟢 Gitroot killed"
130fi
131ssh-keygen -f "$HOME/.ssh/known_hosts" -R "[127.0.0.1]:$SERVER_PORT"
132
133##### launch gitroot
134report "🏁 launch gitroot"
135
136cd ${SCRIPT_DIR}/../server
137mkdir -p "${SERVER_DATA_DIR}"
138go run -race . -initConfig="${SERVER_DATA_DIR}/config"
139sed -i -e "s/sshaddr: 0.0.0.0:4545/sshaddr: 0.0.0.0:$SERVER_PORT/g" "${SERVER_DATA_DIR}/config"
140sed -i -e "s/httpaddr: 0.0.0.0:4546/httpaddr: 0.0.0.0:$SERVER_PORT_HTTP/g" "${SERVER_DATA_DIR}/config"
141sed -i -e "s/activesftp: false/activesftp: true/g" "${SERVER_DATA_DIR}/config"
142GIT_TRACE_PACKET=false go run -race . -data="${SERVER_DATA_DIR}" -config="${SERVER_DATA_DIR}/config" &>> $MY_LOG &
143
144wait_for "starting SSH server on" $MY_LOG
145
146##### forgeConfig
147report "🏁 forgeConfig"
148
149cd /tmp
150quiet_git clone -c "core.sshCommand=ssh -i ${SSH_KEY} -o IdentitiesOnly=yes -o StrictHostKeyChecking=accept-new" ${ROOT_REPO_URL}
151cd ${ROOT_REPO_NAME}
152init_local_git forgeConfig@gitroot.dev forgeConfig ${SSH_KEY}.pub ${SSH_KEY}
153
154printf "${REPO1_NAME}:\n defaultbranch: main" >> .gitroot/repositories.yml
155quiet_git add .
156quiet_git commit -m "create first repo"
157quiet_git push origin main
158report "🟢 ${ROOT_REPO_NAME} push first repo"
159
160mySleep 0.05
161
162##### Repo1
163report "🏁 Repo1"
164
165cd /tmp
166GIT_SSH_COMMAND="ssh -i ${SSH_KEY} -o IdentitiesOnly=yes" quiet_git clone --quiet "${REPO1_URL}"
167cd ${REPO1_NAME}
168init_local_git repo1@gitroot.dev user1 ${SSH_KEY}.pub ${SSH_KEY}
169
170quiet_git add .
171quiet_git commit -m "init user"
172report "🟢 ${REPO1_NAME} commit user"
173
174quiet_git checkout -b "branch1"
175quiet_git push origin main branch1
176report "🟢 ${REPO1_NAME} push main+branch1"
177quiet_git checkout main
178quiet_git push origin :branch1
179report "🟢 ${REPO1_NAME} delete :branch1"
180quiet_git push origin main
181report "🟢 ${REPO1_NAME} push empty main"
182
183##### first plugin
184report "🏁 first plugin"
185
186cd /tmp/${ROOT_REPO_NAME}
187echo "- purl: ${LADYBUG_WASM}" >> .gitroot/plugins.yml
188quiet_git add .
189quiet_git commit -m "init ladybug plugin"
190printf "\n${REPO2_NAME}:\n defaultbranch: main" >> .gitroot/repositories.yml
191quiet_git add .
192quiet_git commit -m "create second repo"
193quiet_git push origin main
194report "🟢 ${ROOT_REPO_NAME} push first plugin and second repo"
195
196wait_ls "${SERVER_DATA_DIR}/data/plugins/gitroot-ladybug"
197
198if [[ $(ls "${SERVER_DATA_DIR}/data/plugins/gitroot-ladybug" | wc -l) -eq 3 ]]; then
199 report "🟢 ${SERVER_DATA_DIR}/data/plugins/gitroot-ladybug loaded"
200else
201 report "🛑 ${SERVER_DATA_DIR}/data/plugins/gitroot-ladybug not downloaded"
202 EXIT_CODE=1
203fi
204
205quiet_git pull origin main
206
207if grep -Fxq " - path: issues/**/*.md" .gitroot/plugins.yml
208then
209 report "🟢 ${ROOT_REPO_NAME} plugin ladybug initialized"
210else
211 report "🛑 ${ROOT_REPO_NAME} plugin ladybug not initialized"
212 EXIT_CODE=1
213fi
214
215if grep -Fxq " metadata:" .gitroot/plugins.yml
216then
217 report "🟢 ${ROOT_REPO_NAME} plugin config initialized"
218else
219 report "🛑 ${ROOT_REPO_NAME} not initialized"
220 EXIT_CODE=1
221fi
222
223if grep -Fxq " - gitroot-ladybug@localhost" .gitroot/users.yml
224then
225 report "🟢 ${ROOT_REPO_NAME} plugin user initialized"
226else
227 report "🛑 ${ROOT_REPO_NAME} plugin user not initialized"
228 EXIT_CODE=1
229fi
230
231cd /tmp
232GIT_SSH_COMMAND="ssh -i ${SSH_KEY} -o IdentitiesOnly=yes" quiet_git clone --quiet "${REPO2_URL}"
233cd ${REPO2_NAME}
234init_local_git repo2@gitroot.dev user1 ${SSH_KEY}.pub ${SSH_KEY}
235
236if grep -Fxq " metadata:" .gitroot/plugins.yml
237then
238 report "🟢 ${REPO2_NAME} plugin config initialized"
239else
240 report "🛑 ${REPO2_NAME} not initialized"
241 EXIT_CODE=1
242fi
243
244if grep -q " - path: issues/\\*\\*/\\*.md" .gitroot/plugins.yml
245then
246 report "🟢 ${REPO2_NAME} plugin path initialized"
247else
248 report "🛑 ${REPO2_NAME} not initialized"
249 EXIT_CODE=1
250fi
251
252sed -i -e 's/active: false/active: true/g' .gitroot/plugins.yml
253
254mkdir issues
255echo "#my Issue" >> issues/1.md
256echo "Beatiful issue" >> issues/1.md
257quiet_git add .
258quiet_git commit -m "first issue in second repo"
259quiet_git push origin main
260report "🟢 ${REPO2_NAME} first issue in second repo"
261
262mySleep 0.05
263
264quiet_git pull
265
266if grep -q "priority: 50" issues/1.md
267then
268 report "🟢 issues/1.md initialized"
269else
270 report "🛑 issues/1.md not initialized"
271 EXIT_CODE=1
272fi
273
274##### repo1 should have issue available
275report "🏁 repo1 should have issue available"
276
277cd /tmp/${REPO1_NAME}
278
279quiet_git pull
280
281if grep -q " - path: issues/\\*\\*/\\*.md" .gitroot/plugins.yml
282then
283 report "🟢 ${REPO1_NAME} plugin path initialized"
284else
285 report "🛑 ${REPO1_NAME} not initialized"
286 EXIT_CODE=1
287fi
288
289sed -i -e 's/active: false/active: true/g' .gitroot/plugins.yml
290
291mkdir issues
292echo "#my Issue" >> issues/1.md
293echo "Beatiful issue" >> issues/1.md
294quiet_git add .
295quiet_git commit -m "first issue in first repo"
296quiet_git push origin main
297report "🟢 ${REPO1_NAME} first issue in first repo"
298
299mySleep 0.05
300
301quiet_git pull
302
303if grep -q "priority: 50" issues/1.md
304then
305 report "🟢 issues/1.md initialized"
306else
307 report "🛑 issues/1.md not initialized"
308 EXIT_CODE=1
309fi
310
311##### user2 rights
312report "🏁 user2 rights"
313
314cd /tmp
315GIT_SSH_COMMAND="ssh -i ${SSH_KEY2} -o IdentitiesOnly=yes" quiet_git clone --quiet "${REPO1_URL}" ${REPO1_NAME}_2
316cd ${REPO1_NAME}_2
317git config core.sshCommand "ssh -i ${SSH_KEY2} -o IdentitiesOnly=yes"
318git config user.email user2repo1@gitroot.dev
319git config user.name user2
320
321echo "# my Issue" >> issues/cac-1.md
322echo "Beatiful issue" >> issues/cac-1.md
323
324quiet_git add .
325quiet_git commit -m "user2 config and add an issue"
326EXPECTED_ERROR=1
327quiet_git push origin main
328if [[ "$?" == "0" ]]; then
329 report "🛑 user2 has push on main in repo1"
330 EXIT_CODE=1
331else
332 report "🟢 user2 can not push on main in repo1"
333fi
334EXPECTED_ERROR=0
335
336quiet_git reset --soft HEAD~1
337quiet_git checkout -b user2_branch_on_repo1
338quiet_git add .
339quiet_git commit -m "user2 config and an issue"
340
341echo "# my Issue" >> issues/cac-2.md
342echo "Beatiful issue" >> issues/cac-2.md
343quiet_git add .
344quiet_git commit -m "issue cac2"
345
346quiet_git push origin user2_branch_on_repo1
347
348if [[ "$?" == "0" ]]; then
349 report "🟢 user2 can push on user2_branch_on_repo1 branch in repo1"
350else
351 report "🛑 user2 can not push on user2_branch_on_repo1 branch in repo1"
352 EXIT_CODE=1
353fi
354
355mySleep 0.05
356quiet_git pull origin user2_branch_on_repo1
357
358if grep -q "priority: 50" issues/cac-1.md
359then
360 report "🟢 issues/cac-1.md initialized"
361else
362 report "🛑 issues/cac-1.md not initialized"
363 EXIT_CODE=1
364fi
365
366echo "New readme" > "README.md"
367quiet_git add .
368quiet_git commit -m "update readme"
369quiet_git push origin user2_branch_on_repo1
370
371if [[ "$?" == "0" ]]; then
372 report "🟢 user2 can push on user2_branch_on_repo1 branch in repo1 second time"
373else
374 report "🛑 user2 can not push on user2_branch_on_repo1 branch in repo1 second time"
375 EXIT_CODE=1
376fi
377
378quiet_git checkout main
379
380cd /tmp/${REPO1_NAME}
381quiet_git fetch origin user2_branch_on_repo1
382quiet_git checkout user2_branch_on_repo1
383
384echo "New readme by user 1" > "README.md"
385quiet_git add .
386quiet_git commit -m "update readme"
387quiet_git push origin user2_branch_on_repo1
388report "🟢 user1 can push on user2_branch_on_repo1 branch in repo1"
389
390quiet_git checkout main
391
392##### user3
393report "🏁 user3 on repo2"
394
395cd /tmp
396GIT_SSH_COMMAND="ssh -i ${SSH_KEY3} -o IdentitiesOnly=yes" quiet_git clone --quiet "${REPO1_URL}" ${REPO1_NAME}_3
397cd ${REPO1_NAME}_3
398git config core.sshCommand "ssh -i ${SSH_KEY3} -o IdentitiesOnly=yes"
399git config user.email user3repo1@gitroot.dev
400git config user.name user3
401
402quiet_git checkout user2_branch_on_repo1
403
404echo "New readme by user 3" > "README.md"
405quiet_git add .
406quiet_git commit -m "update readme"
407
408EXPECTED_ERROR=1
409quiet_git push origin user2_branch_on_repo1
410if [[ "$?" == "0" ]]; then
411 report "🛑 user3 has push on user2_branch_on_repo1 in repo1"
412 EXIT_CODE=1
413else
414 report "🟢 user3 can not push on user2_branch_on_repo1 in repo1"
415fi
416EXPECTED_ERROR=0
417
418cd /tmp/${REPO1_NAME}
419quiet_git pull
420sed -i -e 's/nbmaxbranchesbeforerejectinganonymous: 10/nbmaxbranchesbeforerejectinganonymous: 1/g' .gitroot/repoConfiguration.yml
421quiet_git add .
422quiet_git commit -m "limit anonymous"
423quiet_git push origin main
424
425cd /tmp/${REPO1_NAME}_3
426quiet_git checkout main
427quiet_git checkout -b test22
428
429EXPECTED_ERROR=1
430quiet_git push origin test22
431if [[ "$?" == "0" ]]; then
432 report "🛑 user3 has push test22 in repo1"
433 EXIT_CODE=1
434else
435 report "🟢 user3 can not push test22 in repo1"
436fi
437EXPECTED_ERROR=0
438
439cd /tmp/${REPO1_NAME}
440sed -i -e 's/nbmaxbranchesbeforerejectinganonymous: 1/nbmaxbranchesbeforerejectinganonymous: 10/g' .gitroot/repoConfiguration.yml
441quiet_git add .
442quiet_git commit -m "unlimit anonymous"
443quiet_git push origin main
444cd /tmp/${REPO1_NAME}_3
445quiet_git push origin test22
446report "🟢 user3 can push test22 in repo1"
447
448##### second plugin
449report "🏁 second plugin"
450
451cd /tmp/${ROOT_REPO_NAME}
452echo "- purl: ${SILO_WASM}" >> .gitroot/plugins.yml
453quiet_git add .
454quiet_git commit -m "init silo plugin"
455quiet_git push origin main
456echo "🟢 ${ROOT_REPO_NAME} push second plugin"
457
458wait_ls "${SERVER_DATA_DIR}/data/plugins/gitroot-silo"
459
460quiet_git pull origin main
461
462cd /tmp/${REPO1_NAME}
463
464quiet_git pull
465
466if grep -q "title: "Roadmaps"" .gitroot/plugins.yml
467then
468 report "🟢 ${REPO1_NAME} plugin path initialized"
469else
470 report "🛑 ${REPO1_NAME} not initialized"
471 EXIT_CODE=1
472fi
473
474sed -i -e 's/active: false/active: true/g' .gitroot/plugins.yml
475
476echo "---" >> issues/roadmap1.md
477echo "id: 22C3" >> issues/roadmap1.md
478echo "priority: 50" >> issues/roadmap1.md
479echo "assignee: null" >> issues/roadmap1.md
480echo "kind: 'roadmap'" >> issues/roadmap1.md
481echo "---" >> issues/roadmap1.md
482echo "# step 1: conquers the world" >> issues/roadmap1.md
483echo "" >> issues/roadmap1.md
484echo "To do that just imagine the world is small." >> issues/roadmap1.md
485
486echo "---" >> issues/roadmap2.md
487echo "id: 22C3" >> issues/roadmap2.md
488echo "priority: 10" >> issues/roadmap2.md
489echo "assignee: null" >> issues/roadmap2.md
490echo "kind: 'roadmap'" >> issues/roadmap2.md
491echo "---" >> issues/roadmap2.md
492echo "# step 2: profit" >> issues/roadmap2.md
493echo "" >> issues/roadmap2.md
494echo "Finally take in peace." >> issues/roadmap2.md
495
496quiet_git add .
497quiet_git commit -m "active silo and build first roadmap ticket"
498quiet_git push origin main
499
500mySleep 0.1
501
502quiet_git pull
503
504if grep -q "issues/roadmap1.md" boards/roadmap.md
505then
506 report "🟢 ${REPO1_NAME} roadmap initialized"
507else
508 report "🛑 ${REPO1_NAME} roadmap not initialized"
509 EXIT_CODE=1
510fi
511
512if grep -q "issues/1.md" boards/issues.md
513then
514 report "🟢 ${REPO1_NAME} issues board initialized"
515else
516 report "🛑 ${REPO1_NAME} issues board not initialized"
517 EXIT_CODE=1
518fi
519
520if grep -q "issues/1.md" boards/triage.md
521then
522 report "🟢 ${REPO1_NAME} triage board initialized"
523else
524 report "🛑 ${REPO1_NAME} triage board not initialized"
525 EXIT_CODE=1
526fi
527
528quiet_git pull --rebase origin main
529
530for (( i=0; i<=50; i++ ))
531do
532 echo "# My issue $i" >> issues/issue_$i.md
533 echo "" >> issues/issue_$i.md
534 echo "Beatiful issue" >> issues/issue_$i.md
535done
536
537quiet_git add .
538quiet_git commit -m "create lot of issues"
539quiet_git push origin main
540
541mySleep 0.5
542
543quiet_git pull
544
545for (( i=0; i<=50; i++ ))
546do
547 PRIO=$(shuf -i 0-99 -n 1)
548 sed -i -e "s/priority: 50/priority: $PRIO/g" issues/issue_$i.md
549done
550
551quiet_git add .
552quiet_git commit -m "update random prio of lot of issues"
553quiet_git push origin main
554
555mySleep 0.05
556
557quiet_git pull
558
559##### Repo2 don't allow anonymous contrib
560report "🏁 Repo2 don't allow anonymous contrib"
561
562cd /tmp/${REPO2_NAME}
563
564quiet_git pull
565
566echo "" >> .gitroot/users.yml
567echo "\"*\":" >> .gitroot/users.yml
568echo " branches:" >> .gitroot/users.yml
569echo " - name: \"*\"" >> .gitroot/users.yml
570echo " users: []" >> .gitroot/users.yml
571
572quiet_git add .
573quiet_git commit -m "block all modifications of anonymous users"
574quiet_git push origin main
575
576cd /tmp
577GIT_SSH_COMMAND="ssh -i ${SSH_KEY2} -o IdentitiesOnly=yes" quiet_git clone --quiet "${REPO2_URL}" ${REPO2_NAME}_2
578cd ${REPO2_NAME}_2
579init_local_git user2repo2@gitroot.dev user2 ${SSH_KEY2}.pub ${SSH_KEY2}
580
581quiet_git checkout -b tryToAddMe
582quiet_git add .
583quiet_git commit -m "user2 config"
584
585EXPECTED_ERROR=1
586quiet_git push origin tryToAddMe
587if [[ "$?" == "0" ]]; then
588 report "🛑 user2 can push on tryToAddMe branch in repo2"
589 EXIT_CODE=1
590else
591 report "🟢 user2 can not push on tryToAddMe branch in repo2"
592fi
593EXPECTED_ERROR=0
594
595##### User2 can add issue in repo1 on branch user2_issue_on_repo1
596report "🏁 User2 can add issue in repo1 on branch user2_issue_on_repo1"
597
598cd /tmp/${REPO1_NAME}_2
599
600quiet_git pull origin main
601
602quiet_git checkout -b user2_issue_on_repo1
603
604echo "# My issue" >> issues/2.md
605echo "" >> issues/2.md
606echo "This is my issue" >> issues/2.md
607
608quiet_git add .
609quiet_git commit -m "user2 issue 1"
610
611echo "---" >> issues/roadmap3.md
612echo "id: 22E3" >> issues/roadmap3.md
613echo "priority: 40" >> issues/roadmap3.md
614echo "assignee: null" >> issues/roadmap3.md
615echo "kind: 'roadmap'" >> issues/roadmap3.md
616echo "---" >> issues/roadmap3.md
617echo "# step 3: give" >> issues/roadmap3.md
618echo "" >> issues/roadmap3.md
619echo "Just fun." >> issues/roadmap3.md
620
621quiet_git add .
622quiet_git commit -m "user2 roadmap 3"
623
624quiet_git push origin user2_issue_on_repo1 :user2_branch_on_repo1
625push_and_wait origin user2_issue_on_repo1
626
627quiet_git pull origin user2_issue_on_repo1
628
629if grep -q "id:" issues/2.md
630then
631 report "🟢 ${REPO1_NAME}_2 issues/2.md initialized"
632else
633 report "🛑 ${REPO1_NAME}_2 issues/2.md not initialized"
634 EXIT_CODE=1
635fi
636
637if grep -q "step 3: give" boards/roadmap.md
638then
639 report "🛑 ${REPO1_NAME}_2 boards/roadmap should not be updated has silo is only on main"
640 EXIT_CODE=1
641else
642 report "🟢 ${REPO1_NAME}_2 boards/roadmap not updated"
643fi
644
645quiet_git checkout -b user2_issue2_on_repo1
646
647echo "# My issue" >> issues/3.md
648echo "" >> issues/3.md
649echo "This is my issue" >> issues/3.md
650
651quiet_git add .
652quiet_git commit -m "user2 issue 2"
653push_and_wait origin user2_issue2_on_repo1
654
655quiet_git pull origin user2_issue2_on_repo1
656
657if grep -q "id:" issues/3.md
658then
659 report "🟢 ${REPO1_NAME}_2 issues/3.md initialized"
660else
661 report "🛑 ${REPO1_NAME}_2 issues/3.md not initialized"
662 EXIT_CODE=1
663fi
664
665NB_SILO=$(grep "step 3: give" boards/roadmap.md | wc -l)
666if [[ "$NB_SILO" == "0" ]]; then
667 report "🟢 ${REPO1_NAME}_2 silo has not been called"
668else
669 report "🛑 ${REPO1_NAME}_2 silo has been called $NB_SILO times"
670 EXIT_CODE=1
671fi
672
673##### User1 push force in repo1 on main
674report "🏁 User1 push force in repo1 on main"
675cd /tmp/${REPO1_NAME}
676mySleep 0.1
677quiet_git pull
678echo "not authorized" > issues/1.md
679quiet_git add .
680quiet_git commit --amend --no-edit
681
682EXPECTED_ERROR=1
683quiet_git push -f origin main
684if [[ "$?" == "0" ]]; then
685 report "🛑 user1 can push force on main"
686 EXIT_CODE=1
687else
688 report "🟢 user1 can not push force on main"
689fi
690EXPECTED_ERROR=0
691quiet_git fetch origin main
692quiet_git reset --hard origin/HEAD
693
694##### User2 push force in repo1 on branch user2_branch2_on_repo1
695report "🏁 User2 push force in repo1 on branch user2_branch2_on_repo1"
696
697cd /tmp/${REPO1_NAME}_2
698quiet_git checkout main
699quiet_git checkout -b user2_branch2_on_repo1
700
701#add a commit
702cd /tmp/${REPO1_NAME}
703quiet_git checkout main
704echo "hello" >> README.md
705quiet_git add .
706quiet_git commit -m "fake commit to conflict"
707quiet_git push origin main
708
709mySleep 0.2
710
711cd /tmp/${REPO1_NAME}_2
712echo "---" >> issues/roadmap4.md
713echo "id: 22C3" >> issues/roadmap4.md
714echo "priority: 50" >> issues/roadmap4.md
715echo "assignee: null" >> issues/roadmap4.md
716echo "kind: 'roadmap'" >> issues/roadmap4.md
717echo "---" >> issues/roadmap4.md
718echo "# step 1: conquers the world" >> issues/roadmap4.md
719echo "" >> issues/roadmap4.md
720echo "To do that just imagine the world is small." >> issues/roadmap4.md
721
722quiet_git add .
723quiet_git commit -m "roadmap4"
724quiet_git push origin user2_branch2_on_repo1
725
726quiet_git checkout main
727quiet_git pull --rebase origin main
728quiet_git checkout user2_branch2_on_repo1
729
730quiet_git rebase -X ours main
731report "🟢 Rebase ok"
732
733quiet_git push -f origin user2_branch2_on_repo1
734mySleep 0.05
735quiet_git pull origin user2_branch2_on_repo1
736report "🟢 Push -f ok"
737
738NB_SILO=$(grep "step 1:" boards/roadmap.md | wc -l)
739if [[ "$NB_SILO" == "1" ]]; then
740 report "🟢 ${REPO1_NAME}_2 silo has not been called"
741else
742 report "🛑 ${REPO1_NAME}_2 silo has been called $NB_SILO times"
743 EXIT_CODE=1
744fi
745
746##### Add grafter plugin in repo1
747report "🏁 Add grafter plugin in repo1"
748
749cd /tmp/${ROOT_REPO_NAME}
750echo "- purl: ${GRAFTER_WASM}" >> .gitroot/plugins.yml
751quiet_git add .
752quiet_git commit -m "init grafter plugin"
753quiet_git push origin main
754
755wait_ls "${SERVER_DATA_DIR}/data/plugins/gitroot-grafter"
756quiet_git pull origin main
757
758cd /tmp/${REPO1_NAME}
759quiet_git pull origin main
760sed -i -e 's/active: false/active: true/g' .gitroot/plugins.yml
761report "🟢 ${REPO1_NAME} grafter plugin initialized"
762quiet_git add .
763quiet_git commit -m "active grafter plugin"
764quiet_git push origin main
765
766report "🟢 ${REPO1_NAME} grafter plugin activated"
767quiet_git checkout -b graft_something
768echo "hello" >> tada.md
769quiet_git add .
770quiet_git commit -m "first graft"
771push_and_wait origin graft_something
772quiet_git pull origin graft_something
773
774NB_STATUS_DRAFT=$(grep "status: draft" grafts/graft_something.md | wc -l)
775if [[ $NB_STATUS_DRAFT -ge 1 ]]; then
776 report "🟢 ${REPO1_NAME} status: draft ok"
777else
778 report "🛑 ${REPO1_NAME} status: draft ko"
779 EXIT_CODE=1
780fi
781report "🟢 ${REPO1_NAME} first graft created"
782
783rm issues/1.md
784quiet_git add .
785quiet_git commit -m "rm issue first graft"
786echo "second" > issues/2.md
787quiet_git add .
788quiet_git commit -m "second issue first graft"
789mv issues/roadmap1.md issues/roadmap.md
790quiet_git add .
791quiet_git commit -m "move roadmap first graft"
792push_and_wait origin graft_something
793quiet_git pull origin graft_something
794
795NB_PUSH=$(grep "Push " grafts/graft_something.md | wc -l)
796NB_COMMIT=$(grep "### " grafts/graft_something.md | wc -l)
797if [[ "$NB_COMMIT" == "6" ]] && [[ "$NB_PUSH" == "3" ]]; then
798 report "🟢 ${REPO1_NAME} graft has 3 push and 6 commits"
799else
800 report "🛑 ${REPO1_NAME} graft has $NB_PUSH push and $NB_COMMIT commits"
801 EXIT_CODE=1
802fi
803
804NB_COMMIT=$(git log --oneline graft_something ^main | wc -l)
805if [[ $NB_COMMIT -eq 9 ]]; then
806 report "🟢 ${REPO1_NAME} has 9 commits on branch graft_something"
807else
808 report "🛑 ${REPO1_NAME} has $NB_COMMIT commits on branch graft_something"
809 EXIT_CODE=1
810fi
811
812sed -i -e 's/status: draft/status: review/g' grafts/graft_something.md
813quiet_git add .
814quiet_git commit -m "review first graft"
815push_and_wait origin graft_something
816quiet_git pull origin graft_something
817
818NB_STATUS_DRAFT=$(grep "status: draft" grafts/graft_something.md | wc -l)
819if [[ "$NB_STATUS_DRAFT" == "0" ]]; then
820 report "🟢 ${REPO1_NAME} status no more draft"
821else
822 report "🛑 ${REPO1_NAME} status: draft ko"
823 EXIT_CODE=1
824fi
825NB_REVIEWERS=$(grep "reviewers: " grafts/graft_something.md | wc -l)
826if [[ "$NB_REVIEWERS" == "1" ]]; then
827 report "🟢 ${REPO1_NAME} reviewers added"
828else
829 report "🛑 ${REPO1_NAME} reviewers ko"
830 EXIT_CODE=1
831fi
832NB_MENTION_OF_REVIEW=$(grep "review first graft" grafts/graft_something.md | wc -l)
833if [[ "$NB_MENTION_OF_REVIEW" == "0" ]]; then
834 report "🟢 ${REPO1_NAME} commit review skipped"
835else
836 report "🛑 ${REPO1_NAME} commit review not skipped"
837 EXIT_CODE=1
838fi
839report "🟢 ${REPO1_NAME} first graft ready to review"
840
841echo "second is 2" > issues/2.md
842quiet_git add .
843quiet_git commit -m "second issue review first graft"
844push_and_wait origin graft_something
845quiet_git pull origin graft_something
846
847NB_DIFF=$(grep -F '```diff' grafts/graft_something.md | wc -l)
848if [[ "$NB_DIFF" == "5" ]]; then
849 report "🟢 ${REPO1_NAME} diff added"
850else
851 report "🛑 ${REPO1_NAME} diff ko $NB_DIFF"
852 EXIT_CODE=1
853fi
854
855sed -i -e 's/status: review/status: merge/g' grafts/graft_something.md
856quiet_git add .
857quiet_git commit -m "merge first graft"
858quiet_git push origin graft_something
859
860mySleep 0.5
861
862quiet_git checkout main
863quiet_git pull --rebase origin main
864quiet_git fetch --prune
865BRANCH_EXIST=$(git branch -r | grep "origin/graft_something" | wc -l)
866if [[ "$BRANCH_EXIST" == "0" ]]; then
867 report "🟢 ${REPO1_NAME} branch graft_something deleted"
868else
869 report "🛑 ${REPO1_NAME} branch graft_something no deleted"
870 EXIT_CODE=1
871fi
872
873report "🟢 ${REPO1_NAME} recreate branch graft_something for test shallow-exclude"
874quiet_git checkout graft_something
875sed -i -e 's/status: merge/status: draft/g' grafts/graft_something.md
876quiet_git add .
877quiet_git commit -m "draft first graft"
878quiet_git push origin graft_something
879quiet_git checkout main
880
881##### Add apex plugin in repo1
882report "🏁 Add apex plugin in repo1"
883
884cd /tmp/${ROOT_REPO_NAME}
885echo "- purl: ${APEX_WASM}" >> .gitroot/plugins.yml
886echo "- purl: ${APEX_CODE_MERMAID_WASM}" >> .gitroot/plugins.yml
887echo "- purl: ${APEX_CODE_WASM}" >> .gitroot/plugins.yml
888echo "- purl: ${APEX_MARKDOWN_WASM}" >> .gitroot/plugins.yml
889quiet_git add .
890quiet_git commit -m "init apex plugin"
891quiet_git push origin main
892
893wait_ls "${SERVER_DATA_DIR}/data/plugins/gitroot-apex_markdown"
894wait_ls "${SERVER_DATA_DIR}/data/plugins/gitroot-apex"
895wait_ls "${SERVER_DATA_DIR}/data/plugins/gitroot-apex_code"
896quiet_git pull origin main
897report "🟢 ${ROOT_REPO_NAME} apex plugin installed"
898
899cd /tmp/${REPO1_NAME}
900quiet_git pull origin main
901sed -i -e 's/active: false/active: true/g' .gitroot/plugins.yml
902sed -i -e 's/layout: \[\]/layout:\
903 \- glob: issues\/**\
904 path: layout.html/g' .gitroot/plugins.yml
905echo "<dl>" > layout.html
906echo " <dt>priority</dt><dd>{{priority}}</dd>" >> layout.html
907echo " <dt>status</dt><dd>{{status}}</dd>" >> layout.html
908echo " <dt>kind</dt><dd>{{kind}}</dd>" >> layout.html
909echo "</dl>" >> layout.html
910echo "<br />" >> layout.html
911echo "{{content}}" >> layout.html
912report "🟢 ${REPO1_NAME} apex plugin initialized"
913quiet_git add .
914quiet_git commit -m "active apex plugin"
915
916push_and_wait origin main
917
918META_FOUND=$(wget -q http://127.0.0.1:$SERVER_PORT_HTTP/repo1/issues/issue_9.html -O - | grep "<dt>" | wc -l)
919if [[ $META_FOUND -eq 3 ]]; then
920 report "🟢 issue_9.html has 3 meta"
921else
922 report "🛑 issue_9.html has no meta"
923 EXIT_CODE=1
924fi
925
926quiet_git pull origin main
927
928report "🟢 ${REPO1_NAME} apex plugin activated"
929echo "# hello" > hello2.md
930echo "## hello2" >> hello2.md
931echo "### hello3" >> hello2.md
932quiet_git add .
933quiet_git commit -m "first html"
934
935quiet_git push origin main
936
937sed -i -e 's/style: simple.min.css/style: style.css/g' .gitroot/plugins.yml
938sed -i -e 's/header: <h1>{{repo.name}}/header: <h1>{{repo.name}} <small>{{page.title}}<\/small>/g' .gitroot/plugins.yml
939
940cp ${SCRIPT_DIR}/../server/resources/styles/simple.min.css style.css
941cat ${SCRIPT_DIR}/../plugins/apex/resources/styles/add.css >> style.css
942echo "body { background-color: 010409 }" >> style.css
943echo "body > header { background-color: 010409; text-align: left; padding: 0 1rem }" >> style.css
944echo "body > header h1 { font-size: 1rem }" >> style.css
945echo "header > nav ul { place-content: normal }" >> style.css
946echo "header > nav a { margin: 0 .5rem; border: 0 }" >> style.css
947
948echo "# Mermaid" >> apex.md
949echo "" >> apex.md
950echo "Examples of rendering mermaid..." >> apex.md
951echo "" >> apex.md
952echo "## Mermaid flowchart" >> apex.md
953echo "" >> apex.md
954echo "\`\`\`mermaid" >> apex.md
955echo "flowchart LR;" >> apex.md
956echo "ssh-->runtime-->plugin" >> apex.md
957echo "\`\`\`" >> apex.md
958echo "" >> apex.md
959echo "## Mermaid flowchart complexe" >> apex.md
960echo "\`\`\`mermaid" >> apex.md
961echo "flowchart TB" >> apex.md
962echo " subgraph Git" >> apex.md
963echo " A[ssh conn] --> B[plugin manager]" >> apex.md
964echo " end" >> apex.md
965echo " subgraph Runtime" >> apex.md
966echo " C[runtime] --> D[wasm]" >> apex.md
967echo " end" >> apex.md
968echo " subgraph Plugin" >> apex.md
969echo " E[guest] --> F[host]" >> apex.md
970echo " end" >> apex.md
971echo " B --> C" >> apex.md
972echo " D --> E" >> apex.md
973echo "" >> apex.md
974echo "\`\`\`" >> apex.md
975echo "## Mermaid pie" >> apex.md
976echo "\`\`\`mermaid" >> apex.md
977echo "pie title Plugins sdk" >> apex.md
978echo " "Stable" : 20" >> apex.md
979echo " "Need work" : 80" >> apex.md
980echo "\`\`\`" >> apex.md
981echo "## Mermaid sequence" >> apex.md
982echo "\`\`\`mermaid" >> apex.md
983echo "sequenceDiagram" >> apex.md
984echo " Alice ->> Bob: Hello Bob, how are you?" >> apex.md
985echo " Bob-->>John: How about you John?" >> apex.md
986echo " Bob--x Alice: I am good thanks!" >> apex.md
987echo " Bob-x John: I am good thanks!" >> apex.md
988echo " Note right of John: Bob thinks a long<br/>long time, so long<br/>that the text does<br/>not fit on a row." >> apex.md
989echo " Bob-->Alice: Checking with John..." >> apex.md
990echo " Alice->John: Yes... John, how are you?" >> apex.md
991echo "\`\`\`" >> apex.md
992
993quiet_git add .
994quiet_git commit -m "perso style"
995quiet_git push origin main
996
997##### User2 can create repo3
998report "🏁 User2 can create repo3 with master branch"
999
1000cd /tmp/${ROOT_REPO_NAME}
1001sed -i -e 's/active: false/active: true/g' .gitroot/plugins.yml
1002report "🟢 ${ROOT_REPO_NAME} plugins will activate"
1003quiet_git add .
1004quiet_git commit -m "active all plugins"
1005
1006push_and_wait origin main
1007
1008quiet_git pull origin main
1009report "🟢 ${ROOT_REPO_NAME} plugins activated"
1010
1011cd /tmp
1012GIT_SSH_COMMAND="ssh -i ${SSH_KEY2} -o IdentitiesOnly=yes" quiet_git clone --quiet "${ROOT_REPO_URL}" ${ROOT_REPO_NAME}_2
1013cd ${ROOT_REPO_NAME}_2
1014quiet_git checkout -b create_repo3
1015init_local_git user2root@gitroot.dev user2 ${SSH_KEY2}.pub ${SSH_KEY2}
1016PUB=$(cat ${SSH_KEY2}.pub)
1017printf "\n${REPO3_NAME}:\n defaultbranch: master\n owners:\n - ${PUB}" >> .gitroot/repositories.yml
1018quiet_git add .
1019quiet_git commit -m "create repo3"
1020push_and_wait origin create_repo3
1021mySleep 3
1022report "🟢 ${ROOT_REPO_NAME}_2 push create_repo3 repo"
1023
1024cd /tmp/${ROOT_REPO_NAME}
1025quiet_git pull --rebase origin main
1026quiet_git fetch origin create_repo3
1027quiet_git checkout create_repo3
1028sed -i -e 's/status: draft/status: merge/g' grafts/create_repo3.md
1029quiet_git add .
1030quiet_git commit -m "merge create_repo3 graft"
1031
1032push_and_wait origin create_repo3
1033
1034cd /tmp
1035GIT_SSH_COMMAND="ssh -i ${SSH_KEY2} -o IdentitiesOnly=yes" quiet_git clone --quiet "${REPO3_URL}"
1036
1037cd ${REPO3_NAME}
1038init_local_git user2repo3@gitroot.dev user2 ${SSH_KEY2}.pub ${SSH_KEY2}
1039echo "works" > README.md
1040quiet_git add .
1041quiet_git commit -m "mine readme"
1042quiet_git push origin master
1043
1044##### Shallow
1045report "🏁 Shallow"
1046
1047cd /tmp
1048rm -rf repo1_shallow
1049GIT_SSH_COMMAND="ssh -i ${SSH_KEY2} -o IdentitiesOnly=yes" quiet_git clone --quiet --depth 1 ssh://git@127.0.0.1:$SERVER_PORT/repo1 repo1_shallow
1050cd repo1_shallow
1051init_local_git user2repo1Shallow@gitroot.dev user2 ${SSH_KEY2}.pub ${SSH_KEY2}
1052
1053NB_COMMIT=$(git rev-list HEAD --count)
1054if [[ $NB_COMMIT -eq 1 ]]; then
1055 report "🟢 repo1_shallow has 1 commit"
1056else
1057 report "🛑 repo1_shallow has $NB_COMMIT commits"
1058 EXIT_CODE=1
1059fi
1060
1061# TODO reactive after go-git v6
1062# quiet_git fetch --deepen 1 origin main
1063# NB_COMMIT=$(git rev-list HEAD --count)
1064# if [[ $NB_COMMIT -eq 2 ]]; then
1065# report "🟢 repo1_shallow has 2 commits"
1066# else
1067# report "🛑 repo1_shallow has $NB_COMMIT commits"
1068# EXIT_CODE=1
1069# fi
1070
1071# TODO reactive after go-git v6
1072# quiet_git fetch --shallow-exclude=graft_something origin main
1073# NB_COMMIT=$(git rev-list HEAD --count)
1074# if [[ $NB_COMMIT -eq 11 ]]; then
1075# report "🟢 repo1_shallow has 11 commits"
1076# else
1077# report "🛑 repo1_shallow has $NB_COMMIT commits"
1078# EXIT_CODE=1
1079# fi
1080
1081##### User2 hack repo1
1082report "🏁 User2 hack repo1"
1083
1084cd /tmp/${REPO1_NAME}_2
1085quiet_git checkout main
1086quiet_git pull --rebase origin main
1087
1088NB_NOT_FOUND=$(wget -q http://127.0.0.1:$SERVER_PORT_HTTP/repo1/index2.html -O - | grep "Not found" | wc -l)
1089if [[ $NB_NOT_FOUND -eq 1 ]]; then
1090 report "🟢 index2.html is not found"
1091else
1092 report "🛑 index2.html exist"
1093 EXIT_CODE=1
1094fi
1095
1096quiet_git checkout -b hack
1097
1098#sed -i -e 's/path: branches\/\*\*\/\*/path: "\*\*\/\*"/g' .gitroot/plugins.yml
1099sed -i -e 's/- main/- hack/g' .gitroot/plugins.yml
1100sed -i -e 's/- "!main"/- "!hack"/g' .gitroot/plugins.yml
1101
1102echo "powned!" > index2.md
1103quiet_git add .
1104quiet_git commit -m "hack"
1105push_and_wait origin hack
1106
1107NB_NOT_FOUND=$(wget -q http://127.0.0.1:$SERVER_PORT_HTTP/repo1/index2.html -O - | grep "Not found" | wc -l)
1108if [[ $NB_NOT_FOUND -eq 1 ]]; then
1109 report "🟢 index2.html is not found"
1110else
1111 report "🛑 index2.html exist"
1112 EXIT_CODE=1
1113fi
1114
1115HACK_LINK=$(wget -q http://127.0.0.1:$SERVER_PORT_HTTP/repo1/branches/ -O - | grep "branches/hack.html" | wc -l)
1116if [[ $HACK_LINK -eq 1 ]]; then
1117 report "🟢 hack branch is referenced"
1118else
1119 report "🛑 hack branch is not referenced"
1120 EXIT_CODE=1
1121fi
1122
1123HACK_LINK=$(wget -q http://127.0.0.1:$SERVER_PORT_HTTP/repo1/branches/hack/grafts/hack.html -O - | grep "Not found" | wc -l)
1124if [[ $HACK_LINK -eq 1 ]]; then
1125 report "🛑 hack branch has no graft"
1126 EXIT_CODE=1
1127else
1128 report "🟢 hack branch has graft"
1129fi
1130
1131##### install pollen plugin
1132report "🏁 pollen plugin"
1133
1134cd /tmp/${ROOT_REPO_NAME}
1135quiet_git checkout main
1136quiet_git pull origin main
1137echo "- purl: ${POLLEN_WASM}" >> .gitroot/plugins.yml
1138quiet_git add .
1139quiet_git commit -m "init pollen plugin"
1140push_and_wait origin main
1141wait_ls "${SERVER_DATA_DIR}/data/plugins/gitroot-pollen"
1142mySleep 0.1
1143quiet_git pull origin main
1144report "🟢 ${ROOT_REPO_NAME} pollen plugin installed"
1145
1146cd /tmp/${REPO1_NAME}
1147push_and_wait origin main
1148quiet_git pull origin main
1149sed -i -e 's/active: false/active: true/g' .gitroot/plugins.yml
1150quiet_git add .
1151quiet_git commit -m "active pollen plugin"
1152quiet_git push origin main
1153
1154echo "With rss" > README.md
1155quiet_git add .
1156quiet_git commit -m "with rss"
1157quiet_git push origin main
1158
1159mySleep 4
1160
1161RSS_CONTENT=$(wget -q http://127.0.0.1:$SERVER_PORT_HTTP/repo1/rss/all.xml -O - | grep "with rss" | wc -l)
1162if [[ $RSS_CONTENT -eq 1 ]]; then
1163 report "🟢 rss ok"
1164else
1165 report "🛑 rss ko with $RSS_CONTENT commits"
1166 EXIT_CODE=1
1167fi
1168
1169##### install hop plugin
1170report "🏁 hop plugin"
1171
1172cd /tmp/${ROOT_REPO_NAME}
1173echo "- purl: ${HOP_WASM}" >> .gitroot/plugins.yml
1174quiet_git add .
1175quiet_git commit -m "init hop plugin"
1176push_and_wait origin main
1177wait_ls "${SERVER_DATA_DIR}/data/plugins/gitroot-hop"
1178mySleep 0.1
1179quiet_git pull origin main
1180report "🟢 ${ROOT_REPO_NAME} hop plugin installed"
1181
1182cd /tmp/${REPO1_NAME}
1183push_and_wait origin main
1184quiet_git pull origin main
1185sed -i -e 's/active: false/active: true/g' .gitroot/plugins.yml
1186quiet_git add .
1187quiet_git commit -m "active hop plugin"
1188quiet_git push origin main
1189
1190mySleep 4
1191
1192quiet_git checkout -b testHop
1193echo "Hello from hop" >> README.md
1194quiet_git add .
1195quiet_git commit -m "test hop plugin"
1196push_and_wait origin testHop
1197
1198quiet_git pull origin testHop
1199NB_REPORT=$(grep "❌ No commands executed." grafts/testHop.md | wc -l)
1200if [[ $NB_REPORT -eq 1 ]]; then
1201 report "🟢 report ok"
1202else
1203 report "🛑 report ko with $NB_REPORT reports"
1204 EXIT_CODE=1
1205fi
1206
1207quiet_git checkout main
1208
1209##### verify commit
1210report "🏁 verify commits"
1211
1212cd /tmp/${ROOT_REPO_NAME}
1213quiet_git checkout main
1214quiet_git pull origin main
1215echo "- purl: ${STIGMA_WASM}" >> .gitroot/plugins.yml
1216echo " active: true" >> .gitroot/plugins.yml
1217quiet_git add .
1218quiet_git commit -m "init stigma plugin"
1219push_and_wait origin main
1220wait_ls "${SERVER_DATA_DIR}/data/plugins/gitroot-stigma"
1221mySleep 1.5
1222quiet_git pull origin main
1223report "🟢 ${ROOT_REPO_NAME} stigma plugin installed"
1224
1225cd /tmp/${ROOT_REPO_NAME}
1226cat .gitroot/allowed_signers >> $MY_LOG
1227git reflog show main | awk '{ print $1 }' | xargs git verify-commit &>> $MY_LOG
1228report "🟢 ${ROOT_REPO_NAME}"
1229
1230cd /tmp/${REPO1_NAME}
1231push_and_wait origin main
1232quiet_git pull origin main
1233sed -i -e 's/active: false/active: true/g' .gitroot/plugins.yml
1234quiet_git add .
1235quiet_git commit -m "active stigma plugin"
1236push_and_wait origin main
1237mySleep 1.5
1238quiet_git pull origin main
1239cat .gitroot/allowed_signers >> $MY_LOG
1240git reflog show main | awk '{ print $1 }' | xargs git verify-commit &>> $MY_LOG
1241report "🟢 ${REPO1_NAME}"
1242
1243cd /tmp/${REPO2_NAME}
1244push_and_wait origin main
1245quiet_git pull origin main
1246sed -i -e 's/active: false/active: true/g' .gitroot/plugins.yml
1247quiet_git add .
1248quiet_git commit -m "active stigma plugin"
1249quiet_git push origin main
1250mySleep 1.5
1251quiet_git pull origin main
1252cat .gitroot/allowed_signers >> $MY_LOG
1253# TODO reactive when stigma plugin can add old user
1254# git reflog show main | awk '{ print $1 }' | xargs git verify-commit &>> $MY_LOG
1255# report "🟢 ${REPO2_NAME}"
1256
1257cd /tmp/${REPO1_NAME}_2
1258quiet_git checkout main
1259quiet_git pull origin main
1260quiet_git checkout -b hack2
1261init_local_git user2repo1@gitroot.dev user2 ${SSH_KEY2}.pub ${SSH_KEY2}
1262echo "hello" >> tada.md
1263quiet_git add .
1264quiet_git commit -m "should add me in allowed_user"
1265push_and_wait origin hack2
1266quiet_git pull origin hack2
1267cat .gitroot/allowed_signers >> $MY_LOG
1268git reflog show hack2 | awk '{ print $1 }' | xargs git verify-commit &>> $MY_LOG
1269report "🟢 ${REPO1_NAME}_2"
1270
1271##### verify schedule
1272report "🏁 verify schedule"
1273
1274mySleep 3
1275
1276cd /tmp/${ROOT_REPO_NAME}
1277quiet_git checkout main
1278quiet_git pull origin main
1279echo "- purl: ${FIREFLY_WASM}" >> .gitroot/plugins.yml
1280echo " active: true" >> .gitroot/plugins.yml
1281quiet_git add .
1282quiet_git commit -m "init firefly plugin"
1283push_and_wait origin main
1284wait_ls "${SERVER_DATA_DIR}/data/plugins/gitroot-firefly"
1285push_and_wait origin main
1286quiet_git pull origin main
1287report "🟢 ${ROOT_REPO_NAME} firefly plugin installed"
1288
1289##### verify sftp
1290report "🏁 verify sftp"
1291
1292sftp -P 4545 -i ${SCRIPT_DIR}/user1/ed25519 -o IdentitiesOnly=yes -b- 127.0.0.1:/repo1 <<< "put ${SCRIPT_DIR}/slide.md"
1293MD_FOUND=$(wget -q http://127.0.0.1:$SERVER_PORT_HTTP/repo1/slide.md -O - | grep "# Hello in my prez" | wc -l)
1294if [[ $MD_FOUND -eq 1 ]]; then
1295 report "🟢 slide.md has go to web through sftp"
1296else
1297 report "🛑 slide.md not found"
1298 EXIT_CODE=1
1299fi
1300
1301
1302##### Finish
1303report "🏁 Finish"
1304if grep -q -i "level=ERROR" $MY_LOG
1305then
1306 report "🛑 Logs contains error"
1307 EXIT_CODE=1
1308else
1309 report "🟢 Logs no error"
1310fi
1311
1312if grep -q -i "WARNING: DATA RACE" $MY_LOG
1313then
1314 report "🛑 Logs contains data race"
1315 EXIT_CODE=1
1316else
1317 report "🟢 Logs no data race"
1318fi
1319
1320if [[ $EXIT_CODE -eq 0 ]]; then
1321 report "🟢 All asserts ok"
1322else
1323 report "🛑 Asserts not good"
1324fi
1325
1326report ""
1327report "✎ Find all logs in $MY_LOG"
1328exit $EXIT_CODE