Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pyanderson/githasdiff
Small python script to search for changes using fnmatch patterns. The principal objective is make build processes faster avoiding unnecessary steps.
https://github.com/pyanderson/githasdiff
cd ci cicd continuous-deployment continuous-integration deploy deployment python python3
Last synced: 2 months ago
JSON representation
Small python script to search for changes using fnmatch patterns. The principal objective is make build processes faster avoiding unnecessary steps.
- Host: GitHub
- URL: https://github.com/pyanderson/githasdiff
- Owner: pyanderson
- License: mit
- Created: 2020-05-19T00:37:01.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-07-10T23:45:06.000Z (over 3 years ago)
- Last Synced: 2024-07-29T17:44:05.693Z (5 months ago)
- Topics: cd, ci, cicd, continuous-deployment, continuous-integration, deploy, deployment, python, python3
- Language: Python
- Homepage:
- Size: 19.5 KB
- Stars: 11
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# githasdiff
[![Build Status](https://travis-ci.org/pyanderson/githasdiff.svg?branch=master)](https://travis-ci.org/pyanderson/githasdiff)Small python script to search for changes using [fnmatch](https://docs.python.org/3/library/fnmatch.html) patterns to filter `git diff HEAD~`. The principal objective is make build processes faster checking whats changes before build projects/services.
- The script exits with 0 when changes are found and 1 otherwise.
- If script receives a `command`, it will be executed and exits with `command` exit code.Inspired by [dockerfiles test script](https://github.com/jessfraz/dockerfiles/blob/master/test.sh) from **Jess Frazelle**.
## Configuration
Create a json file named `.githasdiff.json` with `include` and `exclude` patterns for each project/service/build:```json
{
"project_a": {
"include": [
"project_a/*.py"
],
"exclude": [
"project_a/extra_scripts/*.py"
]
}
}
```Global patterns can be defined in same file:
```json
{
"include": [
"*.py"
],
"exclude": [
"*.md"
]
}
```### Observations:
- Global patterns will be always used to search for changes.
- `exclude` has priority over `include` patterns, so first exclude, then matches.
- If `include` patterns list is omitted, then script will considerate `["*"]` as `include` list pattern.It's also possible use an env var `GITHASDIFF_FILE` to set the path to json config file, and an env var `GITHASDIFF_COMMAND` to set command to check for diff.
## Install
```bash
curl -L https://github.com/pyanderson/githasdiff/releases/download/1.0.4/githasdiff > ./githasdiff
chmod +x ./githasdiff
```## Run
Using if/else:
```bash
if ./githasdiff project_a; then docker build -t project_a project_a/; else exit 0; fi
```Using the `command` as args:
```bash
./githasdiff project_a docker build -t project_a project_a/
```## Examples
Check [.githasdiff.json](.githasdiff.json) for configuration and [.travis.yml](.travis.yml) for running.