Here I want detail of files which are present under particular tag or branch.
I tried below GET API but it is returning only commit message of that particular file. But I want file name and other details as well.
https://api.bitbucket.org/2.0/repositories/project_name/repo_name/refs/branches/branch_name
Can someone help me here to fetch details of files present under specific branch or tag.
If you have access to a "git clone" checkout for your repository then the "git ls-tree" command is a great way to get this info, assuming it's up to date (e.g., "git fetch" was recently run).
Example:
git ls-tree -r origin/master
Hello @prajakta101,
I believe /src/{node}/{path} endpoint is what you're looking for. The documentation page looks a bit broken, but node is a branch, a tag, or a commit, while path is path from the root of the repository. This endpoint returns some metadata for each file and directory.
Hope this helps.
Cheers,
Daniil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Daniil,
When I enter file name as PATH then I am getting all details of file. But I want to find file name for particular branch or tag.
Can you please tell me where I can get PATH.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry I don't quite understand what you're trying to get. You can list your repository, starting from root, at any branch or tag, or commit. For example, this is the URL to fetch everything (all files and directories) at the root level of atlassain/atlaskit-mk-2 repository at master branch:
https://api.bitbucket.org/2.0/repositories/atlassian/atlaskit-mk-2/src/master/
Or just their name and type (and pagination attributes):
https://api.bitbucket.org/2.0/repositories/atlassian/atlaskit-mk-2/src/master/?fields=pagelen,page,next,values.path,values.type
The latter would result in something like this:
{
pagelen: 10,
values: [
{
path: ".changeset",
type: "commit_directory"
},
{
path: "__mocks__",
type: "commit_directory"
},
{
path: "build",
type: "commit_directory"
},
{
path: "docs",
type: "commit_directory"
},
{
path: "flow-typed",
type: "commit_directory"
},
{
path: "packages",
type: "commit_directory"
},
{
path: "releases",
type: "commit_directory"
},
{
path: "typings",
type: "commit_directory"
},
{
path: "website",
type: "commit_directory"
},
{
path: ".editorconfig",
type: "commit_file"
}
],
page: 1,
next: "https://bitbucket.org/!api/2.0/repositories/atlassian/atlaskit-mk-2/src/master/?fields=pagelen%2Cpage%2Cnext%2Cvalues.path%2Cvalues.type&page=8xhd"
}
Now this would list files and directories under /docs/guides at branch AK-3659 in the same repository:
https://api.bitbucket.org/2.0/repositories/atlassian/atlaskit-mk-2/src/AK-3659/docs/guides/
If you are rather looking for a name of a particular file on some another branch, i.e. track renames, you need to use the diff API instead. If the file is not listed in the diff, it means that file is same between branches (both content and location).
Let me know if this helps.
Cheers,
Daniil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.