MunifTanjim / node-bitbucket

Bitbucket API client for Browser and Node.js
https://bitbucketjs.netlify.app
MIT License
105 stars 31 forks source link

`repositories.readSrc` and `source.read` unable to list all files in root #136

Closed kevcao-certik closed 6 months ago

kevcao-certik commented 6 months ago

I'm wanting to list all of the files in the root of a repo for a specific commit using repositories.readSrc and source.read, but the returned response does not contain them. I've tried setting the path to "", "/", and forcibly using undefined, none of which work.

Sample Output:

 {
      "data": {
        "path": "",
        "commit": {
          "hash": "409d01ae56f10dc2a2305ff0d22b50648056b38b",
          "links": {
            "self": {
              "href": "https://api.bitbucket.org/2.0/repositories/kevcao-test/test-repo/commit/409d01ae56f10dc2a2305ff0d22b50648056b38b"
            },
            "html": {
              "href": "https://bitbucket.org/kevcao-test/test-repo/commits/409d01ae56f10dc2a2305ff0d22b50648056b38b"
            }
          },
          "type": "commit"
        },
        "type": "commit_directory",
        "links": {
          "self": {
            "href": "https://api.bitbucket.org/2.0/repositories/kevcao-test/test-repo/src/409d01ae56f10dc2a2305ff0d22b50648056b38b//"
          },
          "meta": {
            "href": "https://api.bitbucket.org/2.0/repositories/kevcao-test/test-repo/src/409d01ae56f10dc2a2305ff0d22b50648056b38b//?format=meta"
          }
        }
      },
}

Steps to Reproduce

Using the Bitbucket client, call the repositories.readSrc and repositories.read functions with an empty path:

await client.repositories.readSrc({
    workspace: "kevcao-test",
    repo_slug: "test-repo",
    commit: "409d01ae56f10dc2a2305ff0d22b50648056b38b",
    path: "",
    format: "meta"
});
kevcao-certik commented 6 months ago

Ah it was because I had the format: "meta" -- removed it and it worked