Search code examples
gitlabgitlab-api

Gitlab: List all changed files in a MR via API


How do I list all the changed files in a MR via Gitlab API? I'm working in a CI project and just want to build the necessary code!


Solution

  • You have all the information you need in GitLab's documentation

    Specifically, this is an example of response:

    {
      "id": 21,
    ...
      "changes": [
        {
        "old_path": "VERSION",
        "new_path": "VERSION",
        "a_mode": "100644",
        "b_mode": "100644",
        "diff": "--- a/VERSION\ +++ b/VERSION\ @@ -1 +1 @@\ -1.9.7\ +1.9.8",
        "new_file": false,
        "renamed_file": false,
        "deleted_file": false
        }
      ]
    }
    

    You can extract the file names from changes -> new_path