#git-hook #hook #git #policies #policy #client-side #server-side

bin+lib GitPolicyEnforcer

GitPolicyEnforcer is a command-line tool that helps you enforce Git policies through Git hooks, both server and client side

2 unstable releases

0.3.0 Apr 7, 2022
0.2.0 May 16, 2021

#2912 in Command line utilities

44 downloads per month

MIT/Apache

31KB
724 lines

Build status

GitPolicyEnforcer

This is a command line utility written in Rust, that helps you utilize Git hooks, to enforce various policies.

It currently supports only the update server side Git hook. The goal is to include client side hooks too.

The tool has been developed so far for usage with self-hosted GitLab CE instances, due to internal needs. It should also work though, for bare git servers (maybe with some minor changes).

This is work in progress. You are welcome to contribute if this project is useful to you.

Usage

For now, please check the following YouTube video:

Rust: GitPolicyEnforcer

According to time availability, more documentation will be added, and further development will happen.

On the fly regex validation

You can quickly test you regexes both for successful regex creation and value validation, before deploying by using the respective feature. Example usage:

Expected to succeed:

gpe --regex '^\d test$' --regex-value '1 test'

Expected to fail at value validation:

gpe --regex '^\d test$' --regex-value 'hello world'

Expected to fail during regex creation:

gpe --regex '^\e{1,1}$' --regex-value 'hello world'

Building

You need a Rust installation in order to compile it.

To build GitPolicyEnforcer:

git clone https://github.com/Vagelis-Prokopiou/GitPolicyEnforcer
cd GitPolicyEnforcer
cargo build --release
./target/release/gpe --help

The produced binary is gpe located in the GitPolicyEnforcer/target/release directory.

Licence

GitPolicyEnforcer is distributed under the terms of both the MIT license and the Apache License (Version 2.0).

Dependencies

~5–7.5MB
~130K SLoC