@@ -74,8 +74,10 @@ def checker(payload):
7474 "POST" , "/repos/py-cov-action/foobar/issues/2/comments" , json = checker
7575 )(status_code = 403 )
7676
77- git .register ("git fetch origin main --depth=1000" )()
78- git .register ("git diff --unified=0 FETCH_HEAD...HEAD" )(stdout = DIFF_STDOUT )
77+ # What is the diff of the PR
78+ session .register ("GET" , "/repos/py-cov-action/foobar/pulls/2.diff" )(
79+ text = DIFF_STDOUT
80+ )
7981
8082 result = main .action (
8183 config = pull_request_config (
@@ -155,8 +157,10 @@ def checker(payload):
155157 "POST" , "/repos/py-cov-action/foobar/issues/2/comments" , json = checker
156158 )(status_code = 403 )
157159
158- git .register ("git fetch origin foo --depth=1000" )(stdout = DIFF_STDOUT )
159- git .register ("git diff --unified=0 FETCH_HEAD...HEAD" )(stdout = DIFF_STDOUT )
160+ # What is the diff of the PR
161+ session .register ("GET" , "/repos/py-cov-action/foobar/pulls/2.diff" )(
162+ text = DIFF_STDOUT
163+ )
160164
161165 result = main .action (
162166 config = pull_request_config (
@@ -202,8 +206,10 @@ def test_action__pull_request__post_comment(
202206 # Are there already comments
203207 session .register ("GET" , "/repos/py-cov-action/foobar/issues/2/comments" )(json = [])
204208
205- git .register ("git fetch origin main --depth=1000" )()
206- git .register ("git diff --unified=0 FETCH_HEAD...HEAD" )(stdout = DIFF_STDOUT )
209+ # What is the diff of the PR
210+ session .register ("GET" , "/repos/py-cov-action/foobar/pulls/2.diff" )(
211+ text = DIFF_STDOUT
212+ )
207213
208214 comment = None
209215
@@ -249,8 +255,11 @@ def test_action__push__non_default_branch(
249255 session .register ("GET" , "/repos/py-cov-action/foobar" )(
250256 json = {"default_branch" : "main" , "visibility" : "public" }
251257 )
252- git .register ("git fetch origin main --depth=1000" )(stdout = DIFF_STDOUT )
253- git .register ("git diff --unified=0 FETCH_HEAD...HEAD" )(stdout = DIFF_STDOUT )
258+
259+ # What is the diff of the `other` branch
260+ session .register ("GET" , "/repos/py-cov-action/foobar/compare/main...other.diff" )(
261+ text = DIFF_STDOUT
262+ )
254263
255264 payload = json .dumps ({"coverage" : 30.00 })
256265 # There is an existing badge in this test, allowing to test the coverage evolution
@@ -338,8 +347,10 @@ def test_action__push__non_default_branch__no_pr(
338347 session .register ("GET" , "/repos/py-cov-action/foobar" )(
339348 json = {"default_branch" : "main" , "visibility" : "public" }
340349 )
341- git .register ("git fetch origin main --depth=1000" )(stdout = DIFF_STDOUT )
342- git .register ("git diff --unified=0 FETCH_HEAD...HEAD" )(stdout = DIFF_STDOUT )
350+ # What is the diff of the `other` branch
351+ session .register ("GET" , "/repos/py-cov-action/foobar/compare/main...other.diff" )(
352+ text = DIFF_STDOUT
353+ )
343354
344355 payload = json .dumps ({"coverage" : 30.00 })
345356 # There is an existing badge in this test, allowing to test the coverage evolution
@@ -402,8 +413,10 @@ def test_action__pull_request__force_store_comment(
402413 "/repos/py-cov-action/foobar/contents/data.json" ,
403414 )(text = payload , headers = {"content-type" : "application/vnd.github.raw+json" })
404415
405- git .register ("git fetch origin main --depth=1000" )()
406- git .register ("git diff --unified=0 FETCH_HEAD...HEAD" )(stdout = DIFF_STDOUT )
416+ # What is the diff of the PR
417+ session .register ("GET" , "/repos/py-cov-action/foobar/pulls/2.diff" )(
418+ text = DIFF_STDOUT
419+ )
407420
408421 result = main .action (
409422 config = pull_request_config (FORCE_WORKFLOW_RUN = True , GITHUB_OUTPUT = output_file ),
@@ -433,8 +446,10 @@ def test_action__pull_request__post_comment__no_marker(
433446 "/repos/py-cov-action/foobar/contents/data.json" ,
434447 )(status_code = 404 )
435448
436- git .register ("git fetch origin main --depth=1000" )()
437- git .register ("git diff --unified=0 FETCH_HEAD...HEAD" )(stdout = DIFF_STDOUT )
449+ # What is the diff of the PR
450+ session .register ("GET" , "/repos/py-cov-action/foobar/pulls/2.diff" )(
451+ text = DIFF_STDOUT
452+ )
438453
439454 result = main .action (
440455 config = pull_request_config (COMMENT_TEMPLATE = """foo""" ),
@@ -458,8 +473,10 @@ def test_action__pull_request__annotations(
458473 "/repos/py-cov-action/foobar/contents/data.json" ,
459474 )(status_code = 404 )
460475
461- git .register ("git fetch origin main --depth=1000" )()
462- git .register ("git diff --unified=0 FETCH_HEAD...HEAD" )(stdout = DIFF_STDOUT )
476+ # What is the diff of the PR
477+ session .register ("GET" , "/repos/py-cov-action/foobar/pulls/2.diff" )(
478+ text = DIFF_STDOUT
479+ )
463480
464481 # Who am I
465482 session .register ("GET" , "/user" )(json = {"login" : "foo" })
@@ -500,8 +517,10 @@ def test_action__pull_request__post_comment__template_error(
500517 "/repos/py-cov-action/foobar/contents/data.json" ,
501518 )(status_code = 404 )
502519
503- git .register ("git fetch origin main --depth=1000" )()
504- git .register ("git diff --unified=0 FETCH_HEAD...HEAD" )(stdout = DIFF_STDOUT )
520+ # What is the diff of the PR
521+ session .register ("GET" , "/repos/py-cov-action/foobar/pulls/2.diff" )(
522+ text = DIFF_STDOUT
523+ )
505524
506525 result = main .action (
507526 config = pull_request_config (COMMENT_TEMPLATE = """{%""" ),
0 commit comments