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