Skip to content
play

GitHub Action

Nocommit detector

v2 Latest version

Nocommit detector

play

Nocommit detector

Fail if the string nocommit or nomerge was found in the source

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Nocommit detector

uses: nobssoftware/nocommit@v2

Learn more about this action in nobssoftware/nocommit

Choose a version

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/.