diff --git a/plugins/azure-devops-backend/src/api/AzureDevOpsApi.ts b/plugins/azure-devops-backend/src/api/AzureDevOpsApi.ts index 06b9eded36..d4551fc0d2 100644 --- a/plugins/azure-devops-backend/src/api/AzureDevOpsApi.ts +++ b/plugins/azure-devops-backend/src/api/AzureDevOpsApi.ts @@ -129,18 +129,13 @@ export class AzureDevOpsApi { public async getGitTags( projectName: string, repoName: string, - options: PullRequestOptions, - ): Promise { + ): Promise { this.logger?.debug( - `Calling Azure DevOps REST API, getting up to ${options.top} Pull Requests for Repository ${repoName} for Project ${projectName}`, + `Calling Azure DevOps REST API, getting Git Tags for Repository ${repoName} for Project ${projectName}`, ); const gitRepository = await this.getGitRepository(projectName, repoName); const client = await this.webApi.getGitApi(); - const searchCriteria: GitPullRequestSearchCriteria = { - status: options.status, - }; - const tagRefs: GitRef[] = await client.getRefs( gitRepository.id as string, projectName, @@ -151,11 +146,9 @@ export class AzureDevOpsApi { false, true, ); - this.logger?.warn(JSON.stringify(tagRefs)); - const linkBaseUrl = `${this.webApi.serverUrl}/${encodeURIComponent( projectName, - )}/_git/${encodeURIComponent(repoName)}/pullrequest`; + )}/_git/${encodeURIComponent(repoName)}?version=GT`; const gitTags: GitTag[] = tagRefs.map(tagRef => { return mappedGitTag(tagRef, linkBaseUrl); }); @@ -403,9 +396,11 @@ export function mappedGitTag(gitRef: GitRef, linkBaseUrl: string): GitTag { return { objectId: gitRef.objectId, peeledObjectId: gitRef.peeledObjectId, - name: gitRef.name, + name: gitRef.name?.replace('refs/tags/', ''), createdBy: gitRef.creator?.displayName ?? 'N/A', - link: `${linkBaseUrl}/5`, + link: `${linkBaseUrl}${encodeURIComponent( + gitRef.name?.replace('refs/tags/', '') ?? '', + )}`, }; } diff --git a/plugins/azure-devops-backend/src/service/router.ts b/plugins/azure-devops-backend/src/service/router.ts index e810ca87db..23ed7f146d 100644 --- a/plugins/azure-devops-backend/src/service/router.ts +++ b/plugins/azure-devops-backend/src/service/router.ts @@ -99,25 +99,8 @@ export async function createRouter( router.get('/git-tags/:projectName/:repoName', async (req, res) => { const { projectName, repoName } = req.params; - - const top = req.query.top ? Number(req.query.top) : DEFAULT_TOP; - - const status = req.query.status - ? Number(req.query.status) - : PullRequestStatus.Active; - - const pullRequestOptions: PullRequestOptions = { - top: top, - status: status, - }; - - const gitPullRequest = await azureDevOpsApi.getGitTags( - projectName, - repoName, - pullRequestOptions, - ); - - res.status(200).json(gitPullRequest); + const gitTags = await azureDevOpsApi.getGitTags(projectName, repoName); + res.status(200).json(gitTags); }); router.get('/pull-requests/:projectName/:repoName', async (req, res) => {