Skip to content

Commit

Permalink
monkeypatch get_diff() for shallow checkouts in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
2bndy5 committed Jan 2, 2024
1 parent 573b99c commit 8bb4d24
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/test_misc.py
Expand Up @@ -23,6 +23,7 @@
end_log_group,
)
from cpp_linter.common_fs import list_source_files
import cpp_linter.rest_api.github_api
from cpp_linter.rest_api.github_api import GithubApiClient


Expand Down Expand Up @@ -142,6 +143,12 @@ def test_get_changed_files(
setattr(gh_client, name, value)
if "event_name" in pseudo and pseudo["event_name"] == "pull_request":
gh_client.event_payload = dict(number=19)
if not fake_runner:
# getting a diff in CI (on a shallow checkout) fails
# monkey patch the .git.get_diff() to return nothing
monkeypatch.setattr(
cpp_linter.rest_api.github_api, "parse_diff", lambda *args: ""
)

with requests_mock.Mocker() as mock:
mock.get(
Expand Down

0 comments on commit 8bb4d24

Please sign in to comment.