From f9c4eb559f9fa75902ced0a2b7057b85d8479d50 Mon Sep 17 00:00:00 2001 From: Razvan-Liviu Varzaru Date: Thu, 21 Nov 2024 17:52:38 +0200 Subject: [PATCH 1/4] Upload git patch when pre-commit fails When pre-commit modify files but is not verbose about the changes, one case use git apply pre-commit.patch --- .github/workflows/pre-commit.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index a36f9bb0..cb173486 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -25,3 +25,14 @@ jobs: run: | source .venv/bin/activate make pre-commit-run-all + - name: Generate git patch + if: ${{ failure() }} + run: | + git diff > pre-commit.patch + - name: Upload git patch + if: ${{ failure() }} + uses: actions/upload-artifact@v4 + with: + name: git-patch + path: pre-commit.patch + From 89629d63a80ac3c68d1b89f218905ebdbc9a9eba Mon Sep 17 00:00:00 2001 From: Razvan-Liviu Varzaru Date: Thu, 21 Nov 2024 18:26:58 +0200 Subject: [PATCH 2/4] fix blank lines --- .github/workflows/pre-commit.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index cb173486..b8d8b0dc 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -35,4 +35,3 @@ jobs: with: name: git-patch path: pre-commit.patch - From d4a92175c40a1b26b8506830a8ce90b76ca35646 Mon Sep 17 00:00:00 2001 From: Razvan-Liviu Varzaru Date: Thu, 21 Nov 2024 18:37:05 +0200 Subject: [PATCH 3/4] Demonstration how pre-commit uploads path. Remove this commit after. --- utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils.py b/utils.py index b2e78344..d7719c2b 100644 --- a/utils.py +++ b/utils.py @@ -4,7 +4,6 @@ import sys from datetime import datetime, timedelta -import docker from pyzabbix import ZabbixAPI from twisted.internet import defer @@ -28,6 +27,7 @@ releaseBranches, savedPackageBranches, ) +import docker private_config = {"private": {}} exec(open("/srv/buildbot/master/master-private.cfg").read(), private_config, {}) From 7014f9843733bc4d0f02edfb51311b4169d2613f Mon Sep 17 00:00:00 2001 From: Razvan-Liviu Varzaru Date: Thu, 21 Nov 2024 21:02:02 +0200 Subject: [PATCH 4/4] Run isort/black in check mode printing the diffs --- .pre-commit-config.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7d760ccb..321b2b6f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -76,6 +76,7 @@ repos: hooks: - id: black name: check python formating (black) + args: ["--diff", "--check"] # - repo: https://github.com/asottile/pyupgrade # rev: v3.16.0 # hooks: @@ -87,7 +88,7 @@ repos: hooks: - id: isort name: check python imports order (isort) - args: ["--profile", "black", "--filter-files"] + args: ["--profile", "black", "--filter-files", "--diff", "--check-only"] - repo: local hooks: - id: docker-hadolint