srag/gitreposfetcher Library
Git Repos Fetcher
This is an OpenSource project by studer + raimann ag, CH-Burgdorf (https://studer-raimann.ch)
This project is licensed under the GPL-3.0-only license
Purpose: Only have minimal files/configuration for deployment of multiple git repos
and as alternative for the disadvantages of git submodules
.
Requirements
- git
- composer
Example as ILIAS core and plugins
It's just an example - You can modify for your use case.
Assumed:
- Web root is
/var/www/html
- Work dir is
/var/www
composer.json
First create the following minimal composer.json
file:
{
"require": {
"srag/gitreposfetcher": ">=1.0.0"
},
"scripts": {
"pre-autoload-dump": [
"srag\\GitReposFetcher\\GitReposFetcher::fetchGitRepos"
],
"foreach": [
"srag\\GitReposFetcher\\GitReposFetcher::forEachRepos"
]
}
}
This is needed for auto download this library and not manuel copy it (Redundant code).
If you use ILIAS >= 6, add the follow script too (For direct install ILIAS core dependencies):
...
"scripts": {
"pre-autoload-dump": [
...,
"composer install -d html"
]
}
...
repos.yml
Add a repos.yml
file with a list of ILIAS core and plugins:
repos:
- location: Path
url: git-URL
checkout: Branch, Tag, Commit
- location: ...
url: ...
checkout: ...
Concrete example:
repos:
- location: html
url: https://github.com/ILIAS-eLearning/ILIAS.git
checkout: v5.4.13
- location: html/Customizing/global/plugins/Services/Repository/RepositoryObject/H5P
url: https://github.com/studer-raimann/H5P.git
checkout: v2.6.0
- location: html/Customizing/global/plugins/Services/COPage/PageComponent/H5PPageComponent
url: https://github.com/studer-raimann/H5PPageComponent.git
checkout: v1.4.0
- location: html/Customizing/global/plugins/Services/Cron/CronHook/H5PCron
url: https://github.com/studer-raimann/H5PCron.git
checkout: v1.2.0
You can add git repos
for other things like skin
or Hub2 origins
.
composer.lock
Composer will generate a composer.lock
file with the used versions of this library and its dependencies.
But the lock file will not include used git repos
references.
Please prefer using tags or commits direct instead of branches (Which could be changed any time), if it should be a problem for you.
.gitignore
You can ignore the follow with a .gitignore
file (For local development and for productive servers):
html
vendor
vendor
will be rebuild from composer.lock
.
And html
is/are the path(s) of your cloned git repos
.
This is very important for local development, because it's possible to commit and push it unintentionally and this would contradict the purpose of this tool.
Install
You can install and update ILIAS core and plugins with composer install
.
You can automate this process with a gitlab CLI.
foreach
You can run a command for each repo
composer run-script foreach %command%
In code
...
use srag\GitReposFetcher\x\GitReposFetcher;
...
GitReposFetcher::getInstance()->doFetchGitRepos(string $root);
GitReposFetcher::getInstance()->doForEachRepos(string $root, array $arguments);
...
Requirements
- PHP >=7.0
Adjustment suggestions
You can report bugs or suggestions at https://plugins.studer-raimann.ch/goto.php?target=uihk_srsu_LGRF
There is no guarantee this can be fixed or implemented