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

Dev Env Evolution: Seeking developers productivity, Webinar

Dev Env Evolution: Seeking developers productivity, Webinar

In this webinar we had two talks:

DevEnv Evolution - Seeking Developer Productivity// Haggai Philip Zaguri, DevOps Architect, Group & Tech Lead at Tikal

Read More
Building a Developer Platform: “Behind the Scenes” of application lifecycle management

Building a Developer Platform: “Behind the Scenes” of application lifecycle management

Originally posted on the Israeli Tech Radar on medium.

In the dynamic realm of software development, particularly within agile and cloud-native landscapes, the ability to swiftly adapt and innovate is paramount. This agility, however, often comes with its own set of challenges, especially when it involves the coordination and management of numerous microservices and processes. Herein lies the crux of our narrative: the establishment of a robust developer platform, metaphorically dubbed “The Show” for its ability to seamlessly present the final act to the audience — our customers — without exposing the countless hours and effort invested backstage by developers and operations personnel.

Read More
Have You built your Developer Platform yet? TechRadarCon Talk

Have You built your Developer Platform yet? TechRadarCon Talk

In this talk, I will try to emphasize the adjustments both Cultural alongside the technological ones which any “Cloud-Native Dev” should adjust to in the CloudNative Era. Whilst cloud Environments and Various Architecture styles, such as Serverless and Micro Services, and their effective Deployment schemes, which seemed to have designed a way to deal with the Operational Overhead, by seteling for a blend of work-styles which enable to choose or invest more wisely, the cloudNative development experience has shifted … Engineering platforms are emerging like mushrooms after the “microservices rain”, some have been building one for quite a while

Read More