Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

API 2.0 seach code within branch name

Maksym Salamatov
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 13, 2024

I am using API 2.0 to search files where needed search query is used.

I am using this URL for requests to API:

"api.bitbucket.org/2.0/workspaces/{workspace}/search/code?search_query='{query}'&pagelen=500";

All works well. But it does not search on specified branch. When I mention the branch name, then results are the same, but it should not. For branch name in query I add this to url

"&ref={branch}"

 

How can I mention the branch name in search code query?

1 answer

1 accepted

2 votes
Answer accepted
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 15, 2024

Hello @Maksym Salamatov ,

welcome to the Community!

The Code Search functionality in Bitbucket Cloud is currently limited to only the main branch of the repository. You can configure the main branch by navigating to Repository Settings > Repository Details > expand ADVANCED > Main branch.

With that in mind, it's not possible to define a particular branch to be searched on. The search will always consider the configured main branch:

There are some things to consider regarding how searches are performed:

  • Search uses the main branch in a repository.
    ...

Reference: Code search considerations 

We have an open feature request with our development team to implement the ability to search in other branches as well when using Code Search API:

If you would be interested in that feature, I would recommend adding your Vote there to help our product manager understand the interest. You can also add yourself as a watcher to be notified by email whenever there's any update towards the feature implementation.

I hope that helps to clarify your questions! If you have any additional questions, feel free to ask.

Thank you, @Maksym Salamatov !

Patrik S

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events