From 4ef319f58bba625445834dc5ffe7ad595a27cef9 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 7 Jul 2024 18:58:14 -0400 Subject: [PATCH] add CONTRIBUTING.md, pre-commit hook --- .githooks/pre-commit | 9 +++++++++ CONTRIBUTING.md | 30 ++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100755 .githooks/pre-commit create mode 100644 CONTRIBUTING.md diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 000000000..f623b5d52 --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,9 @@ +#!/bin/sh +# Redirect output to stderr. +exec 1>&2 + +# Run clang-format on staged files; abort the commit if any files are changed +if ! git clang-format ; then + echo "linting made changes to source files; aborting commit" + exit 1 +fi diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..19815c7f6 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,30 @@ +# Contributing to pret/pokeheartgold + + +- [Code Formatting](#code-formatting) + + +This document provides a synopsis and loose guidelines for how to contribute to this project. It is a work in progress. Maintainers should expand this document. + +## Code Formatting + +This repository includes an opinionated `clang-format` specification to ensure that we maintain a common code style. For convenience, a pre-commit hook is also provided in `.githooks` which will run `clang-format` against any staged changes prior to executing a commit. + +### Requirements + +- `clang-format@17` or newer + +### Usage + +To set up the pre-commit hook: + +```sh +git config --local core.hooksPath .githooks/ +``` + +To run the formatter on the full source tree: + +```bash +./format.sh +``` +