microsoft / vss-web-extension-sdk

Visual Studio Teams Service Web Extension SDK
https://www.visualstudio.com/docs/integrate/extensions/overview
MIT License
133 stars 92 forks source link

[Azure DevOps Extension] Getting current repository id #114

Open ravibha opened 5 years ago

ravibha commented 5 years ago

Hi VSS team, Is there an api or some kind of context object that can provide information about the current repository? I am building an extension that needs to show repository information. I know there are apis that get repo information about a repo based on a repository id. But I am not sure how to get the repo id in the context of the repo. Can some one provide guidance on this?

Thanks!

pradeepgudipati commented 5 years ago

Hi

You can use below code to get all Repositories

restClient = RestClient.getClient();  
restClient.getRepositories(projectName, true).then(results => {
                debugger;
                allRepos = results;
     var repoIds = [];
      var repoNames = [];
      for (var i = 0; i < allRepos.length; i++) {
                    var record = allRepos[i];
                    repoIds.push(record.id);
                    repoNames.push(record.name);
          }
});
ecl1ps commented 4 years ago

Hi,

I am also missing this information. Is it possible to retrieve current active repository id through the vss sdk?

Thanks

pradeepgudipati commented 4 years ago

That may be difficult. You need to provide the projectName to get the repo id. But there is no way to get the active repo.

miduncan commented 3 years ago

Is this still the case? I need to retrieve an image from the current repository for my use case, which from my understanding needs to be done through the Git APIs which require the repositoryId. I need to grab it from the current repository, not any others.