From 5d2f33753b438e2336f39ae87ea8e9c435aa643b Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Mon, 25 Nov 2024 09:17:21 +0000 Subject: [PATCH 01/12] fix: update noxfile.py to fix Sessions defined in /workspace/commit-check/noxfile.py: * lint - test-hook - build - install-wheel - commit-check - coverage - docs sessions marked with * are selected, sessions marked with - are skipped. --- noxfile.py | 1 - requirements-dev.txt | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/noxfile.py b/noxfile.py index 3600177..ef78f4a 100644 --- a/noxfile.py +++ b/noxfile.py @@ -2,7 +2,6 @@ import glob nox.options.reuse_existing_virtualenvs = True -nox.options.reuse_venv = True nox.options.sessions = ["lint"] REQUIREMENTS = { diff --git a/requirements-dev.txt b/requirements-dev.txt index cb4cde7..120645f 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,5 +1,5 @@ coverage -nox +git+https://github.com/wntrblm/nox.git@main pre-commit pytest pytest-mock From c92ce259ff041c91859c7fb61afdbb391e769d0f Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Mon, 25 Nov 2024 09:51:43 +0000 Subject: [PATCH 02/12] feat: add docs-live --- noxfile.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index ef78f4a..5097210 100644 --- a/noxfile.py +++ b/noxfile.py @@ -65,6 +65,13 @@ def coverage(session): @nox.session() def docs(session): - session.install("-e", ".") + session.install(".") session.install("-r", REQUIREMENTS["docs"]) session.run("sphinx-build", "-E", "-W", "-b", "html", "docs", "_build/html") + + +@nox.session(name="docs-live") +def docs_live(session): + session.install(".") + session.install("-r", REQUIREMENTS["docs"], "sphinx-autobuild") + session.run("sphinx-autobuild", "-b", "html", "docs", "_build/html") From 4c3993a77f2c9d29c5ad1a9d9fec7a05285bf6fc Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Tue, 26 Nov 2024 13:13:51 +0000 Subject: [PATCH 03/12] docs: update to add example --- README.rst | 55 +++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/README.rst b/README.rst index 465ab34..7b630fc 100644 --- a/README.rst +++ b/README.rst @@ -30,9 +30,11 @@ Commit Check Overview -------- -**Commit Check** is a free, powerful tool that enforces commit metadata standards, including commit message, branch naming, committer name/email, and commit signoff. Fully customizable with error messages and suggested commands, it ensures compliance across teams. +**Commit Check** is a free, powerful tool that enforces commit metadata standards, including commit message, branch naming, committer name/email, commit signoff and more. -As an alternative to GitHub Enterprise `Metadata restrictions `_ and Bitbucket's paid puglin `Yet Another Commit Checker `_, Commit Check stands out by integrating DevOps principles and Infrastructure as Code (IaC). +Fully customizable with error messages and suggested commands, it ensures compliance across teams. + +As an alternative to GitHub Enterprise `Metadata restrictions `_ and Bitbucket's paid plugin `Yet Another Commit Checker `_, Commit Check stands out by integrating DevOps principles and Infrastructure as Code (IaC). Configuration ------------- @@ -70,7 +72,7 @@ Running as pre-commit hook - repo: https://github.com/commit-check/commit-check rev: the tag or revision hooks: # support hooks - - id: check-message # requires hook prepare-commit-msg + - id: check-message # requires prepare-commit-msg hook - id: check-branch - id: check-author-name - id: check-author-email @@ -80,25 +82,25 @@ Running as pre-commit hook Running as CLI ~~~~~~~~~~~~~~ -Global Installation +Install globally .. code-block:: bash sudo pip3 install -U commit-check -User Installation +Install locally .. code-block:: bash pip install -U commit-check -Install from Git Repo +Install from source code .. code-block:: bash pip install git+https://github.com/commit-check/commit-check.git@main -Then, run ``commit-check`` from the command line. For more information, see the `docs `_. +Then, run ``commit-check --help`` from the command line. For more information, see the `docs `_. Running as Git Hooks ~~~~~~~~~~~~~~~~~~~~ @@ -155,24 +157,47 @@ Check Branch Naming Failed Commit rejected by Commit-Check. - (c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c) - / ._. \ / ._. \ / ._. \ / ._. \ / ._. \ - __\( C )/__ __\( H )/__ __\( E )/__ __\( C )/__ __\( K )/__ + (c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c) + / ._. \ / ._. \ / ._. \ / ._. \ / ._. \ + __\( C )/__ __\( H )/__ __\( E )/__ __\( C )/__ __\( K )/__ (_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._) - || E || || R || || R || || O || || R || - _.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._ + || E || || R || || R || || O || || R || + _.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._ (.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.) - `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ + `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ Commit rejected. - Type branch check failed => my-test-branch + Type branch check failed => patch-1 It doesn't match regex: ^(bugfix|feature|release|hotfix|task|chore)\/.+|(master)|(main)|(HEAD)|(PR-.+) - Branches must begin with these types: bugfix/ feature/ release/ hotfix/ task/ chore/ Suggest: run command `git checkout -b type/branch_name` +Check Commit Signature Failed + +.. code-block:: text + + Commit rejected by Commit-Check. + + (c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c) + / ._. \ / ._. \ / ._. \ / ._. \ / ._. \ + __\( C )/__ __\( H )/__ __\( E )/__ __\( C )/__ __\( K )/__ + (_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._) + || E || || R || || R || || O || || R || + _.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._ + (.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.) + `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ + + Commit rejected. + + Type commit_signoff check failed => c92ce259ff041c91859c7fb61afdbb391e769d0f + It doesn't match regex: Signed-off-by:.*[A-Za-z0-9]\s+<.+@.+> + Signed-off-by not found in latest commit + Suggest: run command `git commit -m "conventional commit message" --signoff` + + + Badging your repository ----------------------- From 2e2ba14ffe741d453a21ac256be44ad40660de98 Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Tue, 26 Nov 2024 13:28:01 +0000 Subject: [PATCH 04/12] docs: update to add example --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 7b630fc..2f19257 100644 --- a/README.rst +++ b/README.rst @@ -120,8 +120,8 @@ Save the script file as ``pre-push`` and make it executable: Now, ``git push`` will trigger this hook automatically. -Example -------- +Examples +-------- Check Commit Message Failed From e6cf8f814489d713401a8b8224f0c7088cf13222 Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Tue, 26 Nov 2024 13:38:37 +0000 Subject: [PATCH 05/12] feat: use nox commands in pipeline --- .github/workflows/main.yml | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c7d0c3a..9860cd5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,34 +21,26 @@ jobs: - uses: actions/setup-python@v5 with: python-version: '3.x' - - - name: Install dependencies - run: | - pip install -r requirements-dev.txt - pip install -e . + - run: pip install -r requirements.txt - name: Run pre-commit run: | - pre-commit run --all-files - pre-commit try-repo . + nox -s lint + nox -s test-hook - name: Build wheel - run: python3 -m pip wheel --no-deps -w dist . + run: nox -s build - name: Upload wheel as artifact uses: actions/upload-artifact@v4 with: name: commit-check_wheel path: ${{ github.workspace }}/dist/*.whl - name: Run commit-check - run: | - python3 -m pip install dist/*.whl - commit-check -h - commit-check --message --branch --author-email + run: nox -s commit-check - name: Collect Coverage - run: | - coverage run --source commit_check -m pytest - coverage report && coverage xml + run: nox -s coverage + - uses: codecov/codecov-action@v5.0.2 with: token: ${{ secrets.CODECOV_TOKEN }} @@ -79,7 +71,7 @@ jobs: - name: Install test # using a wildcard as filename on Windows requires a bash shell shell: bash - run: python3 -m pip install dist/*.whl + run: nox -s install-wheel docs: runs-on: ubuntu-latest @@ -88,11 +80,11 @@ jobs: - uses: actions/setup-python@v5 with: python-version: "3.10" - - run: python -m pip install . -r docs/requirements.txt + - run: pip install -r requirements.txt - name: Build docs working-directory: docs - run: sphinx-build -E -W -b html . _build/html + run: nox -s docs - name: Save built docs as artifact uses: actions/upload-artifact@v4 From 0344c7135752232f7aa5af356878d4b3153a59c1 Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Tue, 26 Nov 2024 13:40:22 +0000 Subject: [PATCH 06/12] feat: use nox commands in pipeline --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9860cd5..03f210a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,7 +21,7 @@ jobs: - uses: actions/setup-python@v5 with: python-version: '3.x' - - run: pip install -r requirements.txt + - run: pip install -r requirements-dev.txt - name: Run pre-commit run: | @@ -80,7 +80,7 @@ jobs: - uses: actions/setup-python@v5 with: python-version: "3.10" - - run: pip install -r requirements.txt + - run: pip install -r requirements-dev.txt - name: Build docs working-directory: docs From e7517163442d6dbfea8bef6748988d3fb827a3d5 Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Tue, 26 Nov 2024 13:41:54 +0000 Subject: [PATCH 07/12] fix: remove cd to docs step --- .github/workflows/main.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 03f210a..12e2f14 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -83,7 +83,6 @@ jobs: - run: pip install -r requirements-dev.txt - name: Build docs - working-directory: docs run: nox -s docs - name: Save built docs as artifact From daf615bc9b128b47ff64eddfc0a836b260fe6d11 Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Tue, 26 Nov 2024 13:54:27 +0000 Subject: [PATCH 08/12] fix: get branch name to fix ci failure --- .github/workflows/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 12e2f14..e882946 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -77,6 +77,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} # get current branch name - uses: actions/setup-python@v5 with: python-version: "3.10" From 7bf6d64c5174f42ca60861b19e9e77130574f0c9 Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Tue, 26 Nov 2024 14:08:31 +0000 Subject: [PATCH 09/12] fix: update noxfile.py --- noxfile.py | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/noxfile.py b/noxfile.py index 5097210..5ddd07e 100644 --- a/noxfile.py +++ b/noxfile.py @@ -34,26 +34,17 @@ def test_hook(session): session.run("pre-commit", "try-repo", ".") -@nox.session() -def build(session): - session.run("python3", "-m", "pip", "wheel", "--no-deps", "-w", "dist", ".") - - -@nox.session(name="install-wheel", requires=["build"]) +@nox.session(name="install-wheel") def install_wheel(session): + session.run("python3", "-m", "pip", "wheel", "--no-deps", "-w", "dist", ".") whl_file = glob.glob("dist/*.whl") session.install(str(whl_file[0])) -# @nox.session(name="commit-check", requires=["install-wheel"]) -@nox.session(name="commit-check", requires=["install-wheel"]) +@nox.session(name="commit-check") def commit_check(session): - session.run( - "commit-check", - "--message", - "--branch", - "--author-email", - ) + session.install(".") + session.run("commit-check", "--message", "--branch", "--author-email") @nox.session(requires=["install-wheel"]) From 4d34bf1d97e5c8b935d70ffb1168b0abfc2f92f9 Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Tue, 26 Nov 2024 14:11:23 +0000 Subject: [PATCH 10/12] fix: add build session back --- noxfile.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index 5ddd07e..d8863b3 100644 --- a/noxfile.py +++ b/noxfile.py @@ -34,7 +34,12 @@ def test_hook(session): session.run("pre-commit", "try-repo", ".") -@nox.session(name="install-wheel") +@nox.session() +def build(session): + session.run("python3", "-m", "pip", "wheel", "--no-deps", "-w", "dist", ".") + + +@nox.session(name="install-wheel", requires=["build"]) def install_wheel(session): session.run("python3", "-m", "pip", "wheel", "--no-deps", "-w", "dist", ".") whl_file = glob.glob("dist/*.whl") From c83e2dbc43f701cb8f4edb9c1683adc30894d42f Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Tue, 26 Nov 2024 14:34:14 +0000 Subject: [PATCH 11/12] fix: install then run test --- noxfile.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index d8863b3..109e2df 100644 --- a/noxfile.py +++ b/noxfile.py @@ -52,8 +52,9 @@ def commit_check(session): session.run("commit-check", "--message", "--branch", "--author-email") -@nox.session(requires=["install-wheel"]) +@nox.session() def coverage(session): + session.install(".") session.run("coverage", "run", "--source", "commit_check", "-m", "pytest") session.run("coverage", "report") session.run("coverage", "xml") From 3ae5caff6df86964f4c5ef793d1bf7982447da7e Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Tue, 26 Nov 2024 14:41:42 +0000 Subject: [PATCH 12/12] fix: install nox for test --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e882946..0a5169e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -61,6 +61,7 @@ jobs: - uses: actions/setup-python@v5 with: python-version: ${{ matrix.py }} + - run: pip install -r requirements-dev.txt - name: Download wheel artifact uses: actions/download-artifact@v4 pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy