From bf67149d2e0f883917e062380f2ee5d53b65e950 Mon Sep 17 00:00:00 2001 From: Pascal Zimmermann Date: Mon, 7 Jul 2025 07:31:15 +0200 Subject: [PATCH 1/8] feat: Add GHE support --- .github/workflows/pull-request-checks.yml | 6 ++--- README.md | 2 +- action.yml | 18 +++++++++++---- requirements.txt | 1 + src/check_changed_files.py | 27 ++++++++++++++++------- 5 files changed, 38 insertions(+), 16 deletions(-) create mode 100644 requirements.txt diff --git a/.github/workflows/pull-request-checks.yml b/.github/workflows/pull-request-checks.yml index 1200935..dfdc5c0 100644 --- a/.github/workflows/pull-request-checks.yml +++ b/.github/workflows/pull-request-checks.yml @@ -23,10 +23,10 @@ jobs: cache: 'pip' - name: Install the requirements - run: pip install pygit2 + run: pip install -r requirements.txt - name: Execute the unittests - run: python3 -m unittest discover tests + run: PYTHONPATH=src python3 -m unittest discover tests pr-lint: runs-on: ubuntu-latest @@ -50,4 +50,4 @@ jobs: with: github_token: ${{ secrets.GITHUB_TOKEN }} flake8_args: --config=.flake8 - fail_on_error: true + fail_level: "error" diff --git a/README.md b/README.md index 051713e..223d23f 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ This GitHub Action checks for changed files in a Git repository and validates th | checked_location | Enter the location of the files, separated by `;`. Example: `src/;docs/test.txt;tests/test*` | true | | | git_location | Path to the Git repository. | false | (current working directory) | | check_all_files | Enables the check of all defined files and folders in the directory. | false | false | -| github_user_token | Define the used GitHub server user token for Github.com. | false | | +| github_user_token | Define the used GitHub server user token for Github.com. | false | ${{ github.token }} | --- diff --git a/action.yml b/action.yml index 579e978..a4ea40b 100644 --- a/action.yml +++ b/action.yml @@ -19,8 +19,16 @@ inputs: required: false github_user_token: description: "Define the used GitHub server user token for Github.com" - default: "GITHUB_TOKEN" + default: ${{ github.token }} required: false + action_version: + description: "Define the used version of the Github action. The parameter should only be used, if you want force overwrite the default version" + default: ${{ github.action_ref }} + required: false +outputs: + files_changed: + description: "Returns true if changed files are detected and false by default" + value: ${{ steps.check-changed-files.outputs.changed-files }} runs: using: "composite" steps: @@ -28,14 +36,16 @@ runs: uses: actions/checkout@v4 with: repository: ZPascal/check-changed-files-action - ref: v1 - github-server-url: https://oauth2:${{ secrets[inputs.github_user_token] }}@github.com + ref: ${{ inputs.action_version }} + github-server-url: https://github.com + token: ${{ inputs.github_user_token }} - name: Install Python Dependencies run: python3 -m pip install pygit2 shell: bash - name: Check the changed files (wrapper) + id: check-changed-files run: | optional_flags="" if [ -n "${{ inputs.git_location }}" ]; then @@ -44,5 +54,5 @@ runs: if [ "${{ inputs.check_all_files }}" == "true" ]; then optional_flags+=" -caf" fi - python3 src/check_changed_files.py -cl "${{ inputs.checked_location }}" $optional_flags + echo "changed-files=$(python3 src/check_changed_files.py -cl '${{ inputs.checked_location }}' $optional_flags)" >> "$GITHUB_OUTPUT" shell: bash diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..3369058 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +pygit2 \ No newline at end of file diff --git a/src/check_changed_files.py b/src/check_changed_files.py index 940dc86..98cac4b 100644 --- a/src/check_changed_files.py +++ b/src/check_changed_files.py @@ -113,12 +113,9 @@ def _get_changed_files(self) -> list[str]: changed_files.append(filepath) return changed_files - def validate_changed_files(self): + def files_changed(self) -> bool: """ Validates that all changed files are within the allowed checked locations. - - Raises: - ValueError: If no changed files are found. """ changed_files: list[str] = self._get_changed_files() @@ -136,17 +133,31 @@ def validate_changed_files(self): self._logger.info( f"All changed files are allowed in checked location {checked_files_and_folder}." ) - return + return True + else: + self._logger.info( + f"Not all changed files are allowed in checked location {checked_files_and_folder}." + ) + return False else: self._logger.info( f"Changed file {changed_file} is allowed in checked location " f"{checked_files_and_folder}." ) - break + return True + else: + self._logger.info( + f"Changed file {changed_file} is not a part of the checked location " + f"{checked_files_and_folder}." + ) + return False + return False else: - raise ValueError("No changed files found.") + self._logger.info("No changed files found.") + return False if __name__ == "__main__": checked_changed_files: CheckedChangedFiles = CheckedChangedFiles() - checked_changed_files.validate_changed_files() + files_changed: bool = checked_changed_files.files_changed() + print(str(files_changed).lower()) From 8939327e22ff564a8a0c10003d871f18cc505ad8 Mon Sep 17 00:00:00 2001 From: Pascal Zimmermann Date: Sun, 20 Jul 2025 20:46:50 +0200 Subject: [PATCH 2/8] docs: Adjust the documentation --- README.md | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 223d23f..d54e59e 100644 --- a/README.md +++ b/README.md @@ -8,17 +8,19 @@ This GitHub Action checks for changed files in a Git repository and validates th - Define a custom location of the Git repository - Supports checking all files and folders in the directory - The functionality is implemented in Python using the `pygit2` library and fully tested by unit tests +- The action can be used in GitHub Enterprise environments --- ## Inputs -| Name | Description | Required | Default | -|-------------------|----------------------------------------------------------------------------------------------|----------|-----------------------------| -| checked_location | Enter the location of the files, separated by `;`. Example: `src/;docs/test.txt;tests/test*` | true | | -| git_location | Path to the Git repository. | false | (current working directory) | -| check_all_files | Enables the check of all defined files and folders in the directory. | false | false | -| github_user_token | Define the used GitHub server user token for Github.com. | false | ${{ github.token }} | +| Name | Description | Required | Default | +|-------------------|-----------------------------------------------------------------------------------------------------------------------------------|----------|-----------------------------| +| checked_location | Enter the location of the files, separated by `;`. Example: `src/;docs/test.txt;tests/test*` | true | | +| git_location | Path to the Git repository. | false | (current working directory) | +| check_all_files | Enables the check of all defined files and folders in the directory. | false | false | +| github_user_token | Define the used GitHub server user token for Github.com. | false | ${{ github.token }} | +| action_version | Define the used version of the Github action. The parameter should only be used, if you want force overwrite the default version. | false | ${{ github.action_ref }} | --- @@ -54,11 +56,17 @@ jobs: uses: actions/checkout@v4 - name: Check changed files + id: test-changed-files uses: ZPascal/check-changed-files-action@v1 with: checked_location: 'src/;docs/README.md' git_location: './' check_all_files: 'true' + + - name: Test + if: steps.test-changed-files.outputs.files_changed == 'true' + run: | + echo "Files changed: ${{ steps.test-changed-files.outputs.files_changed }}" ``` --- @@ -66,7 +74,13 @@ jobs: ## Output - Logs info about changed files that are allowed or not allowed. -- The workflow fails if changed files are not within the allowed locations. +- Returns true/ false and reports if changed files are detected. + +### Output table + +| Name | Description | +|---------------|------------------------------------------------------------------| +| files_changed | Returns true if changed files are detected and false by default. | --- @@ -79,4 +93,4 @@ jobs: ## License -The gcp-bucket-upload-action is licensed under the [Apache 2.0](LICENSE). +The check-changed-files-action is licensed under the [Apache 2.0](LICENSE). From f76c3ecd8d9a5b5759f8d352349a19f710c82fd3 Mon Sep 17 00:00:00 2001 From: Pascal Zimmermann Date: Thu, 7 Aug 2025 22:56:17 +0200 Subject: [PATCH 3/8] WIP --- src/check_changed_files.py | 20 ++++----- tests/test_check_changed_files.py | 67 ++++++++++++++++++++++++++++--- 2 files changed, 72 insertions(+), 15 deletions(-) diff --git a/src/check_changed_files.py b/src/check_changed_files.py index 98cac4b..e127f77 100644 --- a/src/check_changed_files.py +++ b/src/check_changed_files.py @@ -9,7 +9,7 @@ class CheckedChangedFiles: """ - A class to check for changed files in a Git repository and validates them against a list of allowed files/folders list. + A class to check for changed files in a Git repository and validates them against a list of allowed files/folders. Attributes: _logger (logging.Logger): Logger instance for tracking operations @@ -125,31 +125,31 @@ def files_changed(self) -> bool: if len(changed_files) > 0: for changed_file in changed_files: for checked_files_and_folder in checked_files_and_folders: + print(f"{changed_file} | {checked_files_and_folder}") if checked_files_and_folder in changed_file: if self._check_all_files: checked_files_and_folders_counter += 1 + print(f"{len(changed_files)} | {checked_files_and_folders_counter}") if len(changed_files) == checked_files_and_folders_counter: self._logger.info( - f"All changed files are allowed in checked location {checked_files_and_folder}." + f"All changed files are allowed in checked location {checked_files_and_folders}." ) return True - else: - self._logger.info( - f"Not all changed files are allowed in checked location {checked_files_and_folder}." - ) - return False else: self._logger.info( f"Changed file {changed_file} is allowed in checked location " - f"{checked_files_and_folder}." + f"{checked_files_and_folders}." ) return True + elif not self._check_all_files: + pass else: self._logger.info( f"Changed file {changed_file} is not a part of the checked location " - f"{checked_files_and_folder}." + f"{checked_files_and_folders}." ) + print("HIER1") return False return False else: @@ -157,6 +157,8 @@ def files_changed(self) -> bool: return False +# TODO New unittests + if __name__ == "__main__": checked_changed_files: CheckedChangedFiles = CheckedChangedFiles() files_changed: bool = checked_changed_files.files_changed() diff --git a/tests/test_check_changed_files.py b/tests/test_check_changed_files.py index c618a31..c0f2213 100644 --- a/tests/test_check_changed_files.py +++ b/tests/test_check_changed_files.py @@ -137,10 +137,10 @@ def test_validate_changed_files_with_changes(self, get_changed_files_mock): self.check_changed_files._checked_location = "src/" self.check_changed_files._check_all_files = False self.check_changed_files._logger = MagicMock() - self.check_changed_files.validate_changed_files() + self.assertEqual(True, self.check_changed_files.files_changed()) self.check_changed_files._logger.info.assert_called_with( - "Changed file src/test.py is allowed in checked location src/." + "Changed file src/test.py is allowed in checked location ['src/']." ) @patch("check_changed_files.CheckedChangedFiles._get_changed_files") @@ -151,8 +151,7 @@ def test_validate_changed_files_no_changes(self, get_changed_files_mock): self.check_changed_files._check_all_files = False self.check_changed_files._logger = MagicMock() - with self.assertRaises(ValueError): - self.check_changed_files.validate_changed_files() + self.assertEqual(False, self.check_changed_files.files_changed()) @patch("check_changed_files.CheckedChangedFiles._get_changed_files") def test_validate_changed_files_with_changes_all_changes(self, get_changed_files_mock): @@ -161,8 +160,64 @@ def test_validate_changed_files_with_changes_all_changes(self, get_changed_files self.check_changed_files._checked_location = "src/" self.check_changed_files._check_all_files = True self.check_changed_files._logger = MagicMock() - self.check_changed_files.validate_changed_files() + self.assertEqual(True, self.check_changed_files.files_changed()) + + self.check_changed_files._logger.info.assert_called_with( + "All changed files are allowed in checked location ['src/']." + ) + + @patch("check_changed_files.CheckedChangedFiles._get_changed_files") + def test_validate_changed_files_multiple_locations(self, get_changed_files_mock): + get_changed_files_mock.return_value = ["src/test.py", "docs/README.md"] + + self.check_changed_files._checked_location = "src/;docs/" + self.check_changed_files._check_all_files = True + self.check_changed_files._logger = MagicMock() + + self.assertEqual(True, self.check_changed_files.files_changed()) + + self.check_changed_files._logger.info.assert_called_with( + "All changed files are allowed in checked location docs/." + ) + + @patch("check_changed_files.CheckedChangedFiles._get_changed_files") + def test_validate_changed_files_with_not_allowed_changes(self, get_changed_files_mock): + get_changed_files_mock.return_value = ["temp/test.py"] + + self.check_changed_files._checked_location = "src/" + self.check_changed_files._check_all_files = False + self.check_changed_files._logger = MagicMock() + + self.assertEqual(False, self.check_changed_files.files_changed()) + + self.check_changed_files._logger.info.assert_called_with( + "Changed file temp/test.py is not a part of the checked location ['src/']." + ) + + @patch("check_changed_files.CheckedChangedFiles._get_changed_files") + def test_validate_changed_files_partial_matches_all_files(self, get_changed_files_mock): + get_changed_files_mock.return_value = ["src/test.py", "temp/test.py"] + + self.check_changed_files._checked_location = "src/" + self.check_changed_files._check_all_files = True + self.check_changed_files._logger = MagicMock() + + self.assertEqual(False, self.check_changed_files.files_changed()) + + self.check_changed_files._logger.info.assert_called_with( + "Changed file temp/test.py is not a part of the checked location ['src/']." + ) + + @patch("check_changed_files.CheckedChangedFiles._get_changed_files") + def test_validate_changed_files_multiple_checks(self, get_changed_files_mock): + get_changed_files_mock.return_value = ["src/subfolder/test.py"] + + self.check_changed_files._checked_location = "docs/;src/;test/" + self.check_changed_files._check_all_files = False + self.check_changed_files._logger = MagicMock() + + self.assertEqual(True, self.check_changed_files.files_changed()) self.check_changed_files._logger.info.assert_called_with( - "All changed files are allowed in checked location src/." + "Changed file src/subfolder/test.py is allowed in checked location src/." ) \ No newline at end of file From 716d0f7e5d50f77a128d4df1136b396bbf2bf13b Mon Sep 17 00:00:00 2001 From: Pascal Zimmermann Date: Wed, 3 Sep 2025 22:50:52 +0200 Subject: [PATCH 4/8] feat: Add new unit tests --- src/check_changed_files.py | 24 +++++++-------- tests/test_check_changed_files.py | 49 ++++++++++++++++++++++++------- 2 files changed, 49 insertions(+), 24 deletions(-) diff --git a/src/check_changed_files.py b/src/check_changed_files.py index e127f77..2d14d3c 100644 --- a/src/check_changed_files.py +++ b/src/check_changed_files.py @@ -125,12 +125,10 @@ def files_changed(self) -> bool: if len(changed_files) > 0: for changed_file in changed_files: for checked_files_and_folder in checked_files_and_folders: - print(f"{changed_file} | {checked_files_and_folder}") if checked_files_and_folder in changed_file: if self._check_all_files: checked_files_and_folders_counter += 1 - print(f"{len(changed_files)} | {checked_files_and_folders_counter}") if len(changed_files) == checked_files_and_folders_counter: self._logger.info( f"All changed files are allowed in checked location {checked_files_and_folders}." @@ -142,23 +140,23 @@ def files_changed(self) -> bool: f"{checked_files_and_folders}." ) return True - elif not self._check_all_files: - pass else: - self._logger.info( - f"Changed file {changed_file} is not a part of the checked location " - f"{checked_files_and_folders}." - ) - print("HIER1") - return False + file_found = False + for other_checked_location in checked_files_and_folders: + if other_checked_location in changed_file: + file_found = True + break + if not file_found and checked_files_and_folder == checked_files_and_folders[-1]: + self._logger.info( + f"Changed file {changed_file} is not a part of the checked location " + f"{checked_files_and_folders}." + ) + return False return False else: self._logger.info("No changed files found.") return False - -# TODO New unittests - if __name__ == "__main__": checked_changed_files: CheckedChangedFiles = CheckedChangedFiles() files_changed: bool = checked_changed_files.files_changed() diff --git a/tests/test_check_changed_files.py b/tests/test_check_changed_files.py index c0f2213..f81be1c 100644 --- a/tests/test_check_changed_files.py +++ b/tests/test_check_changed_files.py @@ -1,3 +1,6 @@ +import sys, io, runpy +from contextlib import redirect_stdout + from unittest import TestCase from unittest.mock import patch, MagicMock, Mock @@ -131,7 +134,7 @@ def test_get_changed_files_key_error(self, mock_repo, mock_validate): ) @patch("check_changed_files.CheckedChangedFiles._get_changed_files") - def test_validate_changed_files_with_changes(self, get_changed_files_mock): + def test_files_changed_with_changes(self, get_changed_files_mock): get_changed_files_mock.return_value = ["src/test.py"] self.check_changed_files._checked_location = "src/" @@ -144,7 +147,7 @@ def test_validate_changed_files_with_changes(self, get_changed_files_mock): ) @patch("check_changed_files.CheckedChangedFiles._get_changed_files") - def test_validate_changed_files_no_changes(self, get_changed_files_mock): + def test_files_changed_no_changes(self, get_changed_files_mock): get_changed_files_mock.return_value = [] self.check_changed_files._checked_location = "src/" @@ -154,7 +157,7 @@ def test_validate_changed_files_no_changes(self, get_changed_files_mock): self.assertEqual(False, self.check_changed_files.files_changed()) @patch("check_changed_files.CheckedChangedFiles._get_changed_files") - def test_validate_changed_files_with_changes_all_changes(self, get_changed_files_mock): + def test_files_changed_with_changes_all_changes(self, get_changed_files_mock): get_changed_files_mock.return_value = ["src/test.py"] self.check_changed_files._checked_location = "src/" @@ -167,21 +170,21 @@ def test_validate_changed_files_with_changes_all_changes(self, get_changed_files ) @patch("check_changed_files.CheckedChangedFiles._get_changed_files") - def test_validate_changed_files_multiple_locations(self, get_changed_files_mock): + def test_files_changed_multiple_locations(self, get_changed_files_mock): get_changed_files_mock.return_value = ["src/test.py", "docs/README.md"] - self.check_changed_files._checked_location = "src/;docs/" + self.check_changed_files._checked_location = "src;docs" self.check_changed_files._check_all_files = True self.check_changed_files._logger = MagicMock() self.assertEqual(True, self.check_changed_files.files_changed()) self.check_changed_files._logger.info.assert_called_with( - "All changed files are allowed in checked location docs/." + "All changed files are allowed in checked location ['src', 'docs']." ) @patch("check_changed_files.CheckedChangedFiles._get_changed_files") - def test_validate_changed_files_with_not_allowed_changes(self, get_changed_files_mock): + def test_files_changed_with_not_allowed_changes(self, get_changed_files_mock): get_changed_files_mock.return_value = ["temp/test.py"] self.check_changed_files._checked_location = "src/" @@ -195,7 +198,7 @@ def test_validate_changed_files_with_not_allowed_changes(self, get_changed_files ) @patch("check_changed_files.CheckedChangedFiles._get_changed_files") - def test_validate_changed_files_partial_matches_all_files(self, get_changed_files_mock): + def test_files_changed_partial_matches_all_files(self, get_changed_files_mock): get_changed_files_mock.return_value = ["src/test.py", "temp/test.py"] self.check_changed_files._checked_location = "src/" @@ -209,7 +212,7 @@ def test_validate_changed_files_partial_matches_all_files(self, get_changed_file ) @patch("check_changed_files.CheckedChangedFiles._get_changed_files") - def test_validate_changed_files_multiple_checks(self, get_changed_files_mock): + def test_files_changed_multiple_checks(self, get_changed_files_mock): get_changed_files_mock.return_value = ["src/subfolder/test.py"] self.check_changed_files._checked_location = "docs/;src/;test/" @@ -219,5 +222,29 @@ def test_validate_changed_files_multiple_checks(self, get_changed_files_mock): self.assertEqual(True, self.check_changed_files.files_changed()) self.check_changed_files._logger.info.assert_called_with( - "Changed file src/subfolder/test.py is allowed in checked location src/." - ) \ No newline at end of file + "Changed file src/subfolder/test.py is allowed in checked location ['docs/', 'src/', 'test/']." + ) + + @patch("check_changed_files.CheckedChangedFiles._get_changed_files") + def test_files_changed_returns_false_when_checked_location_is_empty(self, get_changed_files_mock): + get_changed_files_mock.return_value = ["some/path/file.txt"] + + class EmptySplit: + def split(self, sep): + return [] + + self.check_changed_files._checked_location = EmptySplit() + self.check_changed_files._check_all_files = True + self.check_changed_files._logger = MagicMock() + + self.assertFalse(self.check_changed_files.files_changed()) + + @patch("os.path.exists", retun_value=True) + @patch("os.path.isdir", return_value=True) + def test_main_prints_true(self, isdir_mock, exists_mock): + argv = ["check_changed_files.py", "-cl", "src", "-gl", "."] + with patch.object(sys, "argv", argv): + buf = io.StringIO() + with redirect_stdout(buf): + runpy.run_module("check_changed_files", run_name="__main__") + self.assertEqual("true\n", buf.getvalue()) From 3f863702b9b6d6b3b65e23eb349633efbdce1939 Mon Sep 17 00:00:00 2001 From: Pascal Zimmermann Date: Wed, 3 Sep 2025 22:55:30 +0200 Subject: [PATCH 5/8] feat: Update the GH actions and add dependabot support --- .github/CODEOWNERS | 1 + .github/dependabot.yml | 6 ++++++ .github/workflows/publish-release.yml | 2 +- .github/workflows/pull-request-checks.yml | 4 ++-- action.yml | 2 +- 5 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 .github/CODEOWNERS create mode 100644 .github/dependabot.yml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..2027f82 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @ZPascal \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..120c689 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" \ No newline at end of file diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index ecf66d2..7f642e5 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -12,7 +12,7 @@ jobs: steps: - name: Checkout the repository and the branch - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Setup the release version and overwrite the existing major version tag run: | diff --git a/.github/workflows/pull-request-checks.yml b/.github/workflows/pull-request-checks.yml index dfdc5c0..c77d810 100644 --- a/.github/workflows/pull-request-checks.yml +++ b/.github/workflows/pull-request-checks.yml @@ -13,7 +13,7 @@ jobs: python-version: [ '3.12' ] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Set up Python uses: actions/setup-python@v5 @@ -36,7 +36,7 @@ jobs: python-version: [ '3.12' ] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Set up Python uses: actions/setup-python@v5 diff --git a/action.yml b/action.yml index a4ea40b..2380db9 100644 --- a/action.yml +++ b/action.yml @@ -33,7 +33,7 @@ runs: using: "composite" steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: repository: ZPascal/check-changed-files-action ref: ${{ inputs.action_version }} From ce5b4a3a6ae6662625c115adf998253030857ed5 Mon Sep 17 00:00:00 2001 From: Pascal Zimmermann Date: Wed, 3 Sep 2025 22:57:03 +0200 Subject: [PATCH 6/8] fix: Adapt the tests --- tests/test_check_changed_files.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_check_changed_files.py b/tests/test_check_changed_files.py index f81be1c..8f15b64 100644 --- a/tests/test_check_changed_files.py +++ b/tests/test_check_changed_files.py @@ -1,4 +1,6 @@ -import sys, io, runpy +import sys +import io +import runpy from contextlib import redirect_stdout from unittest import TestCase From 5870636ea1299e095e8eb16a859acb0b8bdedb32 Mon Sep 17 00:00:00 2001 From: Pascal Zimmermann Date: Wed, 3 Sep 2025 23:07:16 +0200 Subject: [PATCH 7/8] fix: Adjust the typo --- src/check_changed_files.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/check_changed_files.py b/src/check_changed_files.py index 2d14d3c..6684985 100644 --- a/src/check_changed_files.py +++ b/src/check_changed_files.py @@ -37,7 +37,7 @@ def _parse_args() -> argparse.Namespace: Returns: _checked_location (str): Files and folder to check (semicolon-separated) - _git_location (str): Git location folder as a relative or absolute path (default is current working directory) + _git_location (str): Git location folder as a relative or absolute path (default is the current working directory) _check_all_files (bool): Whether to check all files in the repository (default is False) """ From 9104770a05d9b94feb0d3ab2d4039f2185ad4add Mon Sep 17 00:00:00 2001 From: Pascal Zimmermann Date: Wed, 3 Sep 2025 23:09:59 +0200 Subject: [PATCH 8/8] fix: Adjust the tests --- tests/test_check_changed_files.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_check_changed_files.py b/tests/test_check_changed_files.py index 8f15b64..689863f 100644 --- a/tests/test_check_changed_files.py +++ b/tests/test_check_changed_files.py @@ -243,10 +243,10 @@ def split(self, sep): @patch("os.path.exists", retun_value=True) @patch("os.path.isdir", return_value=True) - def test_main_prints_true(self, isdir_mock, exists_mock): + def test_main_prints_false(self, isdir_mock, exists_mock): argv = ["check_changed_files.py", "-cl", "src", "-gl", "."] with patch.object(sys, "argv", argv): buf = io.StringIO() with redirect_stdout(buf): runpy.run_module("check_changed_files", run_name="__main__") - self.assertEqual("true\n", buf.getvalue()) + self.assertEqual("false\n", buf.getvalue())