GitRoot

Craft your forge // Build your project // Grow your community freely
 1<!--
 2SPDX-FileCopyrightText: 2025 Romain Maneschi <romain@gitroot.dev>
 3
 4SPDX-License-Identifier: CC-BY-SA-4.0
 5-->
 6
 7# Plugin rights
 8
 9Plugins are the true power of GitRoot. But, as you know, with power comes responsability. To be sure to understand what a plugin can and can't, GitRoot expose all details in `.gitroot/plugins.yml`.
10
11## First example
12
13Taking [ladybug](../../plugins/name/ladybug.md) as an example:
14
15```yml
16- purl: pkg:gitroot/gitroot/ladybug@0.0.5?checksum=sha256:7409837469ce89d5c9fd8dd48236764650f4852&registry=https:%2F%2F%2Fgitroot.dev%2Freleases%2F0.5.0
17  active: true
18  run:
19    - path: issues/**/*.md
20      branch:
21        - "*"
22      when:
23        - add
24        - mod
25      write:
26        git:
27          - path: issues/**/*.md
28            can:
29              - mod
30        web: []
31      configuration: ...
32```
33
34You can read: "for all branches in your repository, when you modify or create any markdown file in the directory or a sud-directory of issues execute the plugin. During execution it can write in any markdown file in the directory or a sud-directory of issues in modification."
35
36But it can't create a file in git or write in web.
37
38Be carrefull, the plugin will be called for modification of `issues/1.md`, but it can modify `issues/2.md` if it need to do.
39
40_Configuration has been omitted because it depend on each plugin._
41
42## More complexe example
43
44If you look at the [plugins.yml](../../.gitroot/plugins.yml) of GitRoot itself you will see that [apex plugin](../../plugins/name/apex.md) have a more complexe configuration:
45
46```yml
47- purl: pkg:gitroot/gitroot/apex@0.0.5?checksum=sha256:97fa5fd2b49f7c9d0b9b6b&registry=https:%2F%2F%2Fgitroot.dev%2Freleases%2F0.5.0
48  active: true
49  run:
50    - path: "**/*"
51      branch:
52        - main
53      when:
54        - add
55        - mod
56        - del
57      write:
58        git:
59          - path: index.md
60            can:
61              - add
62        web:
63          - path: "**/*"
64            can:
65              - add
66              - mod
67              - del
68              - append
69      configuration: &apexConf
70        header: ...
71    - path: "**/*"
72      branch:
73        - "*"
74        - "!main"
75      when:
76        - add
77        - mod
78        - del
79      write:
80        git: []
81        web:
82          - path: branches/**/*
83            can:
84              - add
85              - mod
86              - del
87              - append
88      configuration:
89        <<: *apexConf
90        generateGitWorktree: false
91```
92
93You can read it as: "On the main branch, every file can be rendered in the web. An `index.md` can be created in the git worktree. But for all other branches, apex plugin can only write in the `branches` directory".
94
95Why? Because in GitRoot everybody can create a branch. Imagine if a bad person come, create a branch and delete all the content of the repository. Then push it, if apex render that in the web, your repository website will be empty... What we want is: render modif in an other url (e.g. http://myTld.com/myRepo/branches/brach-test/myFile) and when the change are commited to the default branche render in final destination (e.g. http://myTld.com/myRepo/myFile).