Skip to content

avionic-design/git-hooks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Git Hooks

Git Hooks are scripts that run before or after certain events in a Git repository.

Image

Contents

Dependencies

Why?

The goal is to use Git Hooks to improve software development. To do this, Git Hooks are used to automate the following tasks:

  • Linting: Running a linter tool to verify compliance with style guidelines.
  • Formation: Running a formater tool to verify compliance with style guidelines.
  • Automatic Testing: Running unit tests to verify the functionality of the changes.

Commit-msg

Follow and apply the commit-message rules and patterns : https://www.conventionalcommits.org/en/v1.0.0/

  • type: description (Max 50 char)
  • type(scope): description (Max 50 char) — (scope) is optional

What are the Commit-message types?

  • feat (new feature)
  • fix (bug fix)
  • refactor (refactoring production code)
  • style (formatting, missing semi colons, etc; no code change)
  • docs (changes to documentation)
  • test (adding or refactoring tests; no production code change)
  • chore (change buildtools, dependencies, delete files; no production code change)
  • wip (work in progress commit to be squashed — do not push!)
  • merge (merge branch)

Commit-msg installation

  • Download git-hook repo https://github.com/avionic-design/git-hooks/
  • To install the hook, you can either create a symlink to it in . git/hooks , or you can simply copy and paste it into the .git/hooks directory whenever the hook is updated.
  • Git hooks are triggered automatically

Pre-commit

Pre-commit hooks are small scripts or commands that are executed before a version control system commits changes to a codebase. These hooks allow developers to enforce coding standards, run tests, or perform other checks on their code before it is committed. They help ensure that only high-quality and compliant code is added to the repository, reducing the chances of introducing bugs or issues.

Pre-Commit installation

All the following tools (Framework, Python, Bash, and C) need to be installed.

Pre-commit Framework https://pre-commit.com/

Pre-commit is a framework for managing and automating pre-commit hooks. It provides a simple and configurable way to define and run custom checks on your codebase before each commit. Pre-commit integrates seamlessly into your development workflow and can be used with a wide range of programming languages and tools.

Installation:

pip install pre-commit

Pre-commit for python

Style Guide:

Tools:

Installation:

pip install ruff black

Pre-commit for bash

Style Guide:

Tools:

Installation:

sudo apt install -y shellcheck
sudo apt-get -y install shfmt

Pre-commit for C

Style Guide:

Tools:

Installation:

pip install cpplint
sudo apt install clang-format

Configuration

pre-commit install

Summary

Using Git Hooks can improve software development in many ways. However, it is important to consider the drawbacks of Git Hooks and implement the hooks properly to avoid security risks.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published