nobssoftware / nocommit

Prevent committing debug & private code using NOCOMMIT tags

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NOCOMMIT Action and Git hook

GitHub Action and git pre-commit hook to detect a NOMERGE and a NOCOMMIT flag in your code.

Add those markers anywhere in a comment or in a debug printf to avoid accidentally merging temporary code to production.

NOCOMMIT

Use this for code you don’t even wish to commit. Anything you never want to see on CI, e.g. temporary credentials, local dev setup, etc.

You can add a git pre-commit hook to help you catch any accidental commits, see the pre-commit file.

Example:

static int
mul(int x, int y)
{
  printf("debug: mul(%d, %d) called", x, y) // NOCOMMIT
  return x * y;
}

Trying to commit this will raise an error:

$ git commit -va
+  printf("debug: mul(%d, %d) called", x, y) // NOCOMMIT

Adding line containing NOCOMMIT. To ignore, use git commit --no-verify
$

The GitHub action is optional if you use the pre-commit hook.

NOMERGE

Same as NOCOMMIT, but it won’t trip up that pre-commit hook. Use this for changes you want to push to CI, but not merge to master. This is useful for debugging CI or for testing something on deployed infra.

This only works if you have the GitHub Action installed, regardless of the pre-commit hook.

GitHub Action

To automatically detect this in any PR on GitHub, add the following GitHub action:

on:
  - pull_request

name: Syntax
jobs:
  nocommit:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: "nocommit checker"
        uses: nobssoftware/nocommit@v2

License (GPLv3)

Copyright © Hraban Luyat

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 of the License.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

About

Prevent committing debug & private code using NOCOMMIT tags

License:GNU General Public License v3.0


Languages

Language:Shell 95.9%Language:Dockerfile 4.1%