Pre-commit hooks using python library pre-commit

Pre-commit hooks using python library pre-commit

Table of Contents

Pre-commit examples used in just-do-it repository

I really need a strict pre-commit considering the number of branches and tools i’m using. Because the heart of the projects is tasks I want at the bare least .pre-commit-config.yaml to include the task --list-all command considering it compiles all the includes which may change name / location between branches.

so pre-commit-reset so designed to the bare minimum! by design in case you get stuck and i need to re-build it from scratch and on the fly…, it will only work if RESET_PRECOMMIT is not “true”

# cat<<EOF>.pre-commit-config.yaml
repos:
  - repo: local
    hooks:
      - id: run-custom-script
        name: Run /usr/bin/env task --list-all
        entry: /usr/bin/env task --list-all
        # entry: ./posts/pre-commit/pre-commit.sh
        language: script
        pass_filenames: false
        stages: [commit]
      - repo: https://github.com/pre-commit/pre-commit-hooks
        rev: v3.4.0
        hooks:
        - id: check-yaml
            exclude: '^charts/helm-example/.*\.yaml$|^charts/common-helm-lib/.*/test-connection.yaml$'
        - id: check-executables-have-shebangs

want to reset / rest after you tweaked with the template

RESET_PRECOMMIT="true" task pre-commit:1st-run

Available Tasks

The following tasks are available for managing pre-commit hooks:

Info

So a good place to start is the code which is available at hagzag/just-do-it

Core Tasks

  • pre-commit:1st-run - Reset pre-commit configuration to bare minimal
  • pre-commit:gen-default-pre-commit-config - Create the base configuration
  • pre-commit:get - Install pre-commit via homebrew
  • pre-commit:install - Configure pre-commit in local repo
  • pre-commit:run - Run pre-commit on staged files
  • pre-commit:run-all-files - Run pre-commit against all files

Usage Examples

Reset/initialize pre-commit configuration:

RESET_PRECOMMIT="true" task pre-commit:1st-run

Run pre-commit checks on staged files:

task pre-commit:run

Install pre-commit for the first time:

task pre-commit:get pre-commit:install

Task Dependencies

    graph TD
	    A[pre-commit:1st-run] --> B[pre-commit:run-all-files]
	    C[pre-commit:install] --> D[pre-commit:get]
comments powered by Disqus

Related Posts

Kubernetes Control Loops: The Secret Sauce Behind Your Microservice Bliss

Kubernetes Control Loops: The Secret Sauce Behind Your Microservice Bliss

Originally posted on the Israeli Tech Radar on medium.

TLDR; Ever dreamt of a system that manages your microservices like a maestro, constantly keeping them in perfect harmony? Kubernetes makes this a reality with control loops, the magic behind the scenes. Operators take it a step further, letting you customize Kubernetes for even more control over custom workload needs.

Read More
Free & Secure Local Development: Bitwarden Secrets Manager with K3d + Walkthrough

Free & Secure Local Development: Bitwarden Secrets Manager with K3d + Walkthrough

Originally posted on the Israeli Tech Radar on medium.

Free & Secure Local Development: Bitwarden Secrets Manager with K3d + Walkthrough

We all deal with secrets, and managing them effectively is crucial for security, especially when working with local development environments. I’ve personally relied on Bitwarden’s free tier for secure password management for years. I moved from a bunch of tools which I needed to be synchronized and kept in sync with my local machine, not because others are bad, but because Bitwarden has a CLI, Desktop, Chrome extension & web which seemly integrated with my workflows.

Read More
A CloudNative Dev Experience 🎯 | Tikal TechRadarCon 2021

A CloudNative Dev Experience 🎯 | Tikal TechRadarCon 2021

Originally posted on the Israeli Tech Radar on medium.

TLDR; Just when we thought we’ve got it figured out! We learn there’s a better, faster way of doing things, frameworks, abstractions, and methodologies invented to make our development experience easier, and help us during our journey to building a platform. But…Do we really need one?/Should we adopt one? What impact will that have on our product? The following post will try to tackle some of these questions as we explore building a better Developer Experience.

Read More