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