File tree Expand file tree Collapse file tree 4 files changed +83
-0
lines changed Expand file tree Collapse file tree 4 files changed +83
-0
lines changed Original file line number Diff line number Diff line change 1010 entry : ./scripts/validate-eslint.sh
1111 language : script
1212 stages : [commit]
13+ - id : run-samplr
14+ name : Runs the command line samplr to generate sample files
15+ description : " A script to generate sample files."
16+ entry : ./scripts/samplr/run-samplr.sh
17+ language : script
18+ stages : [commit]
Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ This repository contains JOSA's custom pre-commit hooks.
77- [ Validate Flux] ( #validate-flux ) - A script to validate Flux custom resources and Kustomize overlays.
88- [ Validate Eslint] ( #validate-eslint ) - A script to validate eslint rules on Javascript and Typescript files.
99
10+ - [ Run Samplr] ( #run-samplr ) - A script to generate sample files.
11+
1012___
1113
1214## validate-flux
@@ -78,3 +80,33 @@ pre-commit install -t pre-commit
7880```
7981
8082___
83+
84+ ## run-samplr
85+
86+ This script runs the command [ samplr] ( https://github.com/unmultimedio/samplr ) to generate ` .sample ` files in your repo. Please refer to the [ config] ( ./scripts/samplr/.samplr.yml ) in this repo to understand which files are supported.
87+
88+ ### Prerequisites
89+
90+ You need the following to be installed on your machine before running this pre-commit script.
91+
92+ - [ samplr v0.2.1] ( https://github.com/unmultimedio/samplr/releases/tag/v0.2.1 )
93+
94+ ### Usage
95+
96+ Add this to your .pre-commit-config.yaml:
97+
98+ ``` yaml
99+ - repo : https://github.com/jordanopensource/pre-commit-hooks
100+ rev : v0.1.0 # Use the ref you want to point at
101+ hooks :
102+ - id : run-samplr
103+ # - id: ...
104+ ```
105+
106+ After the configuration is added, you'll need to run
107+
108+ ``` bash
109+ pre-commit install -t pre-push
110+ ```
111+
112+ ___
Original file line number Diff line number Diff line change 1+ # #####################
2+ # samplr configuration
3+ # #####################
4+
5+ # Want to include a header that indicates this is an autogenerated file?
6+ autogencomments : true
7+
8+ # regex matches for filenames that you want to include or exclude from
9+ # the samplr generation. Be careful to indent using spaces.
10+ # For a file to be sampled, it has to meet both requirements: be included and not excluded.
11+ excludes :
12+ - \.sample # It's a good idea to exclude all *.sample* files, otherwise it will behave recursively
13+ - \.go$ # Most of the times, the code files won't need samples
14+ - ^vendor # Dependencies shouldn't be sampled
15+ - ^node-modules # Dependencies shouldn't be sampled
16+ includes :
17+ - ^config # Matches files like ./config/setup.yml or ./configuration/script.sh
18+ - \.yml$ # Matches all .yml files in the project
19+ - Dockerfile # Matches all Dockerfile in the project
20+ - .env # Matches all env files in the project
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ # ##############################
4+ # ########## CREDITS: ##########
5+ # https://github.com/unmultimedio/samplr#5-set-up-a-githook-optional
6+ # ######### MODIFIED: ##########
7+ # t.hamoudi
8+ # ######## MAINTAINED: #########
9+ 10+ # ##############################
11+
12+ # ##############################
13+ # Prerequisites
14+ # - samplr v0.2.1
15+ # ##############################
16+ # ##### INSTALLATION GUIDE #####
17+ # https://github.com/unmultimedio/samplr/blob/master/INSTALL.md
18+ # ##############################
19+
20+ set -e
21+
22+ # Run samplr command to generate sample files
23+ samplr
24+ # List all changed and not-ignored files, with a filename that matches with ".sample", and add it to the commit
25+ git ls-files -mo --exclude-standard | grep " \.sample" | xargs git add
You can’t perform that action at this time.
0 commit comments