Added git-tags/ route to server. Client now calls /git-tags/
Signed-off-by: mo <mcassidy@hchb.com>
This commit is contained in:
@@ -123,6 +123,38 @@ export class AzureDevOpsApi {
|
||||
return repoBuilds;
|
||||
}
|
||||
|
||||
public async getGitTags(
|
||||
projectName: string,
|
||||
repoName: string,
|
||||
options: PullRequestOptions,
|
||||
): Promise<PullRequest[]> {
|
||||
this.logger?.debug(
|
||||
`Calling Azure DevOps REST API, getting up to ${options.top} Pull Requests 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 gitPullRequests = await client.getPullRequests(
|
||||
gitRepository.id as string,
|
||||
searchCriteria,
|
||||
projectName,
|
||||
undefined,
|
||||
undefined,
|
||||
options.top,
|
||||
);
|
||||
const linkBaseUrl = `${this.webApi.serverUrl}/${encodeURIComponent(
|
||||
projectName,
|
||||
)}/_git/${encodeURIComponent(repoName)}/pullrequest`;
|
||||
const pullRequests: PullRequest[] = gitPullRequests.map(gitPullRequest => {
|
||||
return mappedPullRequest(gitPullRequest, linkBaseUrl);
|
||||
});
|
||||
|
||||
return pullRequests;
|
||||
}
|
||||
|
||||
public async getPullRequests(
|
||||
projectName: string,
|
||||
repoName: string,
|
||||
|
||||
@@ -97,6 +97,29 @@ export async function createRouter(
|
||||
res.status(200).json(gitRepository);
|
||||
});
|
||||
|
||||
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);
|
||||
});
|
||||
|
||||
router.get('/pull-requests/:projectName/:repoName', async (req, res) => {
|
||||
const { projectName, repoName } = req.params;
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ export class AzureDevOpsClient implements AzureDevOpsApi {
|
||||
if (options?.status) {
|
||||
queryString.append('status', options.status.toString());
|
||||
}
|
||||
const urlSegment = `pull-requests/${encodeURIComponent(
|
||||
const urlSegment = `git-tags/${encodeURIComponent(
|
||||
projectName,
|
||||
)}/${encodeURIComponent(repoName)}?${queryString}`;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user