Skip to content

Invalid toFileRange.lines when using --unified=0 #33

Closed
@pdgendt

Description

@pdgendt

When trying to parse a minimal diff using git diff --unified=0 the resulting lines in toFileRange is the same as the start value.

The following example (adding a single line):

diff --git a/tests/test_commands.py b/tests/test_commands.py
index 8838bb3bb0992afe26109081704e8c67a49a171a..ed42fd1d1e649d1197772f2047d7ce2a4461a533 100644
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -12,0 +13 @@ def test_parse_git_version():
+    # add this

Results in:

{
  "type": "GitDiff",
  "files": [
    {
      "type": "ChangedFile",
      "chunks": [
        {
          "context": "def test_parse_git_version():",
          "type": "Chunk",
          "toFileRange": {
            "start": 13,
            "lines": 13
          },
          "fromFileRange": {
            "start": 12,
            "lines": 0
          },
          "changes": [
            {
              "type": "AddedLine",
              "lineAfter": 13,
              "content": "    # add this"
            }
          ]
        }
      ],
      "path": "tests/test_commands.py"
    }
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions