Skip to content

[FEAT]: Update ReviewComments to use Line instead of PositionΒ #3046

@felix-mohr

Description

@felix-mohr

Describe the need

https://docs.github.com/en/rest/pulls/comments?apiVersion=2022-11-28#create-a-review-comment-for-a-pull-request

The position parameter is closing down, line should be used instead with the side and subject_type parameters.

Notes:

  • the side parameters must be UPPER CASE or left blank for files
  • the subject_type parameter must be lower case and can (must?) be removed if line but is required for file which does not have the line parameter set
  • start_line muss be LESS than line, it cannot have the same value. Remove parameter if single line comment.

I am not sure, but I think the start_side, is defined because of a range comment, must also be equal to side.

As reference, I am using this bit of code, posted via HttpClient, in my migration project.

                int? startLine = null;
                if (position.OldLine.HasValue)
                {
                    startLine = position.LineRange?.Start?.OldLine;
                    payload.line = position.OldLine;
                    payload.side = "LEFT";
                }
                else if (position.NewLine.HasValue)
                {
                    startLine = position.LineRange?.Start?.NewLine;
                    payload.line = position.NewLine;
                    payload.side = "RIGHT";
                }
                else
                {
                    payload.subject_type = "file";
                }

                if (payload.line > startLine)
                {
                    payload.start_line = startLine;
                    payload.start_side = payload.side;
                }

with the JSON serializer set to "remove propertiers with default vaules"

SDK Version

No response

API Version

No response

Relevant log output

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: TriageThis is being looked at and prioritizedType: FeatureNew feature or request

    Type

    No type

    Projects

    Status

    πŸ†• Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions