raliqala / ready

A program to run tasks before a commit.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ready

Ready is a program to run tasks before a commit using a pre-commit git hook.

For example, you can automatically run formatting, linting, and testing when running git commit, so you are assured every commit is up to the standards, issues are spotted early, and to avoid any CI pipeline failures down the road.

For now, tasks are run on all the repository files, not just the staged ones.

At any time, tasks can be run without committing by running ready.

Additionally, to commit without running any task, the -n/--no-verify git commit flag can be used.

Instructions

  1. Install Ready

You can use Go:

go install github.com/lewislbr/ready@latest

Or download the binary from the releases page and place it in your $PATH.

  1. Install hook

Must be run in the repository root path (where the folder .git is located).

ready init

This will check for any existing pre-commit hook, and if found, it will prompt to override it or abort the process. If no hook is found, a new one with execution rights will be created.

  1. Create tasks file

File must be named ready.yaml and placed in the repository root path (where the folder .git is located).

tasks:
  - name: format
    command: gofumpt -l -w .
  - name: lint
    command: golangci-lint run

By default, commands will be run in the root directory, but they can be scoped to nested directories:

tasks:
  - name: format
    command: gofumpt -l -w . # This will run in the root directory (./)
  - name: lint
    directory: app-1
    command: golangci-lint run # This will run in the app-1 directory (./app-1)
  - name: lint
    directory: app-2
    command: golangci-lint run # This will run in the app-2 directory (./app-2)

YAML file reference

tasks: # Array of tasks to be run (required)
  - name: format # Name of the task (required)
    directory: app-1 # Directory where to run the command (optional)
    command: gofumpt -l -w . # Command to run (required)

Example

example-fail

example-success

Contributing

This project started as a way to learn and to solve a need I had. If you think it can be improved in any way, you are very welcome to contribute!

About

A program to run tasks before a commit.

License:MIT License


Languages

Language:Go 100.0%