git-pull-dirigent

Git Pull Dirigent

Git Pull Dirigent is a bash script which aims to automate the whole process of updating a Git repository in an advanced manner and one shot.

Main Features

You can:

Usage

Requirments

Depending on what you want to do with this script, it has different requirements.

php dependencies
node dependencies
compiling assets

### Choosing what to run Git Pull Dirigent’s work is based on the digit combination gpd_cmd which can be found at the begining of the script. Every index in this command is reserved for a specific functionality. By default Git Pull Dirigent will run a digit combination like 11110 which will update your repository and subsequently it will check whether the composer.json was updated, if it does it will run ‘composer install’ command, if not will do nothing. Similarly, it will run ‘npm install’ command if package.json was updated. Finally, using ‘npm run production’ it will run all mix tasks by minifying output for production if and only if any of files which are set to be compiled was changed. What’s good here is that we can have a control over this process and we can modify it by changing only a few variables. Let’s assume that instead of npm we want to use yarn to update our node dependencies, the only thing we should do is to change the digit in the second position (the index which is reserved for the type of PM) in the combination from 1 to 2. In the same way, if we want to run ‘composer update’ we can change only the first digit from 1 to 2. Below is provided a table which helps to create combinations. If you don’t want to run any of aforementioned tasks simply change its digit to 0.

### Controlling when to execute Git Pull Dirigent by default will run tasks asssigned to it only if their respective files get affected during update. For example, if package.json is changed, then gpd will update node dependencies, if not, gpd will not it will skip this process. We can have a control when to run jobs we specified to be done. This can be done by changing the last digit of combination. If this digit is set to 1 it will run always the commands which are specified, if it is 0 it will run them only if their files are changed.

Creating combinations

Git Pull Dirigent can do diffent things by assigning different combinations to gpd_cmd. Instructions on how to use these commands are provided in the table below.

—— – COMPOSER – —– JS PM —- - JS PM CMD - - FILE COMPILE - —- – WHEN– ——-
—— - install update install update install update - prod dev watch always - on update -
—— — 1 — — 2 — —- 1 — — 2 — — 1 — — 2 —- – 1 – - 2 - – 3 – — 1 — — – 0 ——
—— —- —- 1 —- —- —– — 1 —- —- — — 1 ——– — – — – 1 – — —- — — - 0 — — ——-
—— composer install — —— —– npm install — — — —- run prod ——- – on updates only -
—— composer.json — — — — package.json – — —- — – files to compile — ———————-

In this table was described how gpd_cmd=11110, and what selected commands will do.

gpd_cmd examples:

Setting up the executable command

Linux(Ubuntu)

You can either set it to run as a global command or simply put in a project repository. To use it as a global command follow ensuing steps: Open cmd and go to bin:

$ cd /bin

create an file using your text editor, in my case nano:

$ nano gitpulldirigent  

add the content of this script and save it. After this make the file executable:

$ chmod +x gitpulldirigent  

your file is ready to run globaly. To test it, go to the root directory of your project

$ gitpulldirigent

Windows

Clone this script and make sure it is placed in the projects root directory, makes sure you give the read & execute permission to it. Right click in the main directory of your project and select ‘Run Bash Here’ from the menu and run:

$ sh gitpulldirigent.sh

Known issues

Todos

License

MIT