Skip to content

Commit a1ce62a

Browse files
authored
Fix One Line Coverage Report Post (#8229)
1 parent 5538231 commit a1ce62a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

scripts/code_coverage_report/post_incremental_coverage_in_pr.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,15 @@ def add_coverage_comments(client, uncovered_files)
6969
else
7070
comment = generate_comment(COMMENT_HEADER, xcresult_file)
7171
if start_line == line
72-
# One line code comment will only rely on the position param, which is
73-
# 'line' here.
74-
client.create_pull_request_comment(REPO,PULL_REQUEST, comment, TESTING_COMMIT,changed_file['fileName'], line, {:side=>"RIGHT"})
72+
# One line code comment will have nil in start_line and override
73+
# the position param, which is 0 here. The position param is a
74+
# relative number in the `git diff`, instead of a absolute line
75+
# index.
76+
client.create_pull_request_comment(REPO,PULL_REQUEST, comment, TESTING_COMMIT,changed_file['fileName'], 0, {:side=>"RIGHT", :line=>line})
7577
else
7678
# multiple-line code block comment needs start_line and line options,
7779
# which will override the position param.
78-
client.create_pull_request_comment(REPO,PULL_REQUEST, comment, TESTING_COMMIT,changed_file['fileName'],0, {:side=>"RIGHT", :start_line=> start_line, :line=> line})
80+
client.create_pull_request_comment(REPO,PULL_REQUEST, comment, TESTING_COMMIT,changed_file['fileName'],0, {:side=>"RIGHT", :start_line=>start_line, :line=>line})
7981
end
8082
start_line = coverage_line[idx+1]
8183
end

0 commit comments

Comments
 (0)