Skip to content

Discrepancy between Gitlab diff API and go-gitdiff parsed output. #21

@chakravarthysm

Description

@chakravarthysm

Hi,

I'm using go-gitdiff to parse git diff patch files in Gitlab and derive some metrics, I used to do same by using diff response of Gitlab diff API.

I see there is some discrepancy between the results.
If I move & rename certain file with with minimal changes, go-gitdiff patch parsed output shows the file in old path as deleted -

(*gitdiff.File)(0xc00013e480)({
 OldName: (string) (len=59) "adapters/phasedAdapters/executeAdapters/execute_adapters.go",
 NewName: (string) "",
 IsNew: (bool) false,
 IsDelete: (bool) true,
 IsCopy: (bool) false,
 IsRename: (bool) false,
 OldMode: (os.FileMode) -rw-r--r--,
 NewMode: (os.FileMode) ----------,
 OldOIDPrefix: (string) (len=7) "f08cca6",
 NewOIDPrefix: (string) (len=7) "0000000",
 Score: (int) 0

and shows the file at new path as new file -

(*gitdiff.File)(0xc00013e2d0)({
 OldName: (string) "",
 NewName: (string) (len=33) "adapters/phase/execute/execute.go",
 IsNew: (bool) true,
 IsDelete: (bool) false,
 IsCopy: (bool) false,
 IsRename: (bool) false,
 OldMode: (os.FileMode) ----------,
 NewMode: (os.FileMode) -rw-r--r--,
 OldOIDPrefix: (string) (len=7) "0000000",
 NewOIDPrefix: (string) (len=7) "a1d4924",
 Score: (int) 0

whereas in Gitlab MR diff view I get move and rename as -
adapters/phasedAdapters/executeAdapters/execute_adapters.go → adapters/phase/execute/execute.go

In Gitlab diff API, the response for the file I get it as -

 {
        "old_path": "adapters/phasedAdapters/executeAdapters/execute_adapters.go",
        "new_path": "adapters/phase/execute/execute.go",
        "a_mode": "100644",
        "b_mode": "100644",
        "new_file": false,
        "renamed_file": true,
        "deleted_file": false
}

Gitlab determines the file was just renamed and move to different path whereas go-gitdiff assumes it as a new file and considers file at old path as deleted, is this expected?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions