Uploaded image for project: 'Bitbucket Cloud'
  1. Bitbucket Cloud
  2. BCLOUD-16306

Diffstat API does not support file renaming

    XMLWordPrintable

    Details

      Description

      The Diffstat API returns incorrect values for file renaming. Instead of a single value with the renamed status it returns two values with statuses removed and added for old and new path names respectively.

      API Description:
      https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/diffstat/%7Bspec%7D

      Live example

      Bitbucket UI handles renaming correctly:
      https://bitbucket.org/kanonirov_sympli/bbprj/commits/0e3d640490b93f32d657b5301ed5425f52b78b01

      API Request URL:
      https://api.bitbucket.org/2.0/repositories/kanonirov_sympli/bbprj/diffstat/0e3d640490b93f32d657b5301ed5425f52b78b01..05b86900161241613babd5a23c706c3af6fec1ef

      API Response contains added/removed values instead of renamed ones:

      #!json
      
      {
        "pagelen": 500,
        "values": [
          {
            "status": "removed",
            "old": {
              "path": "some path2/Android_L.sketch/document.json",
              "type": "commit_file",
              "links": {
                "self": {
                  "href": "https://api.bitbucket.org/2.0/repositories/kanonirov_sympli/bbprj/src/05b86900161241613babd5a23c706c3af6fec1ef/some%20path2/Android_L.sketch/document.json"
                }
              }
            },
            "lines_removed": 37,
            "lines_added": 0,
            "new": null,
            "type": "diffstat"
          },
          {
            "status": "removed",
            "old": {
              "path": "some path2/Android_L.sketch/meta.json",
              "type": "commit_file",
              "links": {
                "self": {
                  "href": "https://api.bitbucket.org/2.0/repositories/kanonirov_sympli/bbprj/src/05b86900161241613babd5a23c706c3af6fec1ef/some%20path2/Android_L.sketch/meta.json"
                }
              }
            },
            "lines_removed": 28,
            "lines_added": 0,
            "new": null,
            "type": "diffstat"
          },
          {
            "status": "removed",
            "old": {
              "path": "some path2/Android_L.sketch/pages/B493E4D5-1701-446E-ACD4-CE3C9D393E26.json",
              "type": "commit_file",
              "links": {
                "self": {
                  "href": "https://api.bitbucket.org/2.0/repositories/kanonirov_sympli/bbprj/src/05b86900161241613babd5a23c706c3af6fec1ef/some%20path2/Android_L.sketch/pages/B493E4D5-1701-446E-ACD4-CE3C9D393E26.json"
                }
              }
            },
            "lines_removed": 364,
            "lines_added": 0,
            "new": null,
            "type": "diffstat"
          },
          {
            "status": "removed",
            "old": {
              "path": "some path2/Android_L.sketch/previews/preview.png",
              "type": "commit_file",
              "links": {
                "self": {
                  "href": "https://api.bitbucket.org/2.0/repositories/kanonirov_sympli/bbprj/src/05b86900161241613babd5a23c706c3af6fec1ef/some%20path2/Android_L.sketch/previews/preview.png"
                }
              }
            },
            "lines_removed": 0,
            "lines_added": 0,
            "new": null,
            "type": "diffstat"
          },
          {
            "status": "removed",
            "old": {
              "path": "some path2/Android_L.sketch/user.json",
              "type": "commit_file",
              "links": {
                "self": {
                  "href": "https://api.bitbucket.org/2.0/repositories/kanonirov_sympli/bbprj/src/05b86900161241613babd5a23c706c3af6fec1ef/some%20path2/Android_L.sketch/user.json"
                }
              }
            },
            "lines_removed": 9,
            "lines_added": 0,
            "new": null,
            "type": "diffstat"
          },
          {
            "status": "added",
            "old": null,
            "lines_removed": 0,
            "lines_added": 37,
            "new": {
              "path": "some path3/Android_L.sketch/document.json",
              "type": "commit_file",
              "links": {
                "self": {
                  "href": "https://api.bitbucket.org/2.0/repositories/kanonirov_sympli/bbprj/src/ac13faf4490f20bdddc45383513b8dff8ad72127/some%20path3/Android_L.sketch/document.json"
                }
              }
            },
            "type": "diffstat"
          },
          {
            "status": "added",
            "old": null,
            "lines_removed": 0,
            "lines_added": 28,
            "new": {
              "path": "some path3/Android_L.sketch/meta.json",
              "type": "commit_file",
              "links": {
                "self": {
                  "href": "https://api.bitbucket.org/2.0/repositories/kanonirov_sympli/bbprj/src/ac13faf4490f20bdddc45383513b8dff8ad72127/some%20path3/Android_L.sketch/meta.json"
                }
              }
            },
            "type": "diffstat"
          },
          {
            "status": "added",
            "old": null,
            "lines_removed": 0,
            "lines_added": 364,
            "new": {
              "path": "some path3/Android_L.sketch/pages/B493E4D5-1701-446E-ACD4-CE3C9D393E26.json",
              "type": "commit_file",
              "links": {
                "self": {
                  "href": "https://api.bitbucket.org/2.0/repositories/kanonirov_sympli/bbprj/src/ac13faf4490f20bdddc45383513b8dff8ad72127/some%20path3/Android_L.sketch/pages/B493E4D5-1701-446E-ACD4-CE3C9D393E26.json"
                }
              }
            },
            "type": "diffstat"
          },
          {
            "status": "added",
            "old": null,
            "lines_removed": 0,
            "lines_added": 0,
            "new": {
              "path": "some path3/Android_L.sketch/previews/preview.png",
              "type": "commit_file",
              "links": {
                "self": {
                  "href": "https://api.bitbucket.org/2.0/repositories/kanonirov_sympli/bbprj/src/ac13faf4490f20bdddc45383513b8dff8ad72127/some%20path3/Android_L.sketch/previews/preview.png"
                }
              }
            },
            "type": "diffstat"
          },
          {
            "status": "added",
            "old": null,
            "lines_removed": 0,
            "lines_added": 9,
            "new": {
              "path": "some path3/Android_L.sketch/user.json",
              "type": "commit_file",
              "links": {
                "self": {
                  "href": "https://api.bitbucket.org/2.0/repositories/kanonirov_sympli/bbprj/src/ac13faf4490f20bdddc45383513b8dff8ad72127/some%20path3/Android_L.sketch/user.json"
                }
              }
            },
            "type": "diffstat"
          }
        ],
        "page": 1,
        "size": 10
      }
      

        Attachments

          Activity

            People

            Assignee:
            6995b9ed1710 evzijst
            Reporter:
            ilya.kanonirov kanonirov_sympli
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: