Nocommit
Prevent committing debug & private code using NOCOMMIT tags
Install / Use
/learn @nobssoftware/NocommitREADME
- 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:
#+begin_src c static int mul(int x, int y) { printf("debug: mul(%d, %d) called", x, y) // NOCOMMIT return x * y; } #+end_src
Trying to commit this will raise an error:
#+begin_example $ git commit -va
- printf("debug: mul(%d, %d) called", x, y) // NOCOMMIT
Adding line containing NOCOMMIT. To ignore, use git commit --no-verify $ #+end_example
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:
#+begin_src yaml on:
- pull_request
name: Syntax jobs: nocommit: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: "nocommit checker" uses: nobssoftware/nocommit@v3 #+end_src
** 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/.
