Azure DevOps – Tips and Tricks – 16 – How to search for code in branches using Code Search Extension

In this article, we are going to learn how to perform a search in different branches quickly using the Azure DevOps marketplace extension called Code Search.

Advertisements

One of the most common requirements is to perform search in your Azure DevOps git repository. For ex: Let’s say, you would like search for a Class name in your git repo, you can type the class name in the Search bar available in the Azure DevOps portal as shown below.

Azure DevOps – Tips and Tricks – 16 – How to search for code in branches using Code Search Extension – Search

By default, as shown in the above screenshot, Azure DevOps will not be able to search it and it recommend us to install an Azure DevOps marketplace extension called Code Search. Please go ahead and install the extension.

Advertisements

Once you install the extension, search for something in the search bar which would result something shown below.

Azure DevOps – Tips and Tricks – 16 – How to search for code in branches using Code Search Extension – Code Search

The above would happen if you try to search immediately after installing the extension. In my case, I tried to search again after 10 mins and was able to view the results as shown below.

Azure DevOps – Tips and Tricks – 16 – How to search for code in branches using Code Search Extension – Code Search Results

So far, it’s pretty simple and it’s good to find the search results. However, by default, the component only searches in the default branch (in my case it’s master). It doesn’t search in the other branches.

Advertisements

Let’s say, you would like to search for something else (HomeController_develop) as shown below which is in a branch called develop.

Azure DevOps – Tips and Tricks – 16 – How to search for code in branches using Code Search Extension – Code Search – Modify

By default, as the search happens only in default branch (in my case, it’s master), the search wouldn’t shown the results as shown below.

Azure DevOps – Tips and Tricks – 16 – How to search for code in branches using Code Search Extension – Code Search – No Results

As the search didn’t result the search term, we can include non-default branches by clicking on the Include Searchable branches which takes us to the Repository page where you can add more Searchable Branches (up to 5) as shown below.

Azure DevOps – Tips and Tricks – 16 – How to search for code in branches using Code Search Extension – Searchable Branches
Advertisements

Click on the ‘+’ button which opens up a popup where you select the develop branch and add it. Once you add the develop branch, the Searchable Branches section would be something as shown below.

Azure DevOps – Tips and Tricks – 16 – How to search for code in branches using Code Search Extension – Searchable Branches

Let’s now, run the search and select the develop branch in the Branch dropdown as shown below and you could search for any term in the selected branch as well.

Azure DevOps – Tips and Tricks – 16 – How to search for code in branches using Code Search Extension – Searchable develop Branches

That’s how the Code Search extension helps us in searching something in feature branches

Advertisements

Summary

In this article, we have learnt about a new Azure DevOps marketplace extension called Code Search which helps us in searching a term of a git repository from multiple branches.

Advertisements

Do you like this article? If you want to get more updates about these kind of articles, you can join my Learning Groups

WhatsApp

Telegram

Advertisements
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s