UNPKG

azure-devops-node-api

Version:
1,020 lines 226 kB
"use strict"; /* * --------------------------------------------------------- * Copyright(C) Microsoft Corporation. All rights reserved. * --------------------------------------------------------- * * --------------------------------------------------------- * Generated file, DO NOT EDIT * --------------------------------------------------------- */ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const basem = require("./ClientApiBases"); const GitInterfaces = require("./interfaces/GitInterfaces"); class GitApi extends basem.ClientApiBase { constructor(baseUrl, handlers, options) { super(baseUrl, handlers, 'node-Git-api', options); } /** * Create an annotated tag. * * @param {GitInterfaces.GitAnnotatedTag} tagObject - Object containing details of tag to be created. * @param {string} project - Project ID or project name * @param {string} repositoryId - ID or name of the repository. */ createAnnotatedTag(tagObject, project, repositoryId) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, repositoryId: repositoryId }; try { let verData = yield this.vsoClient.getVersioningData("6.0-preview.1", "git", "5e8a8081-3851-4626-b677-9891cc04102e", routeValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.create(url, tagObject, options); let ret = this.formatResponse(res.result, GitInterfaces.TypeInfo.GitAnnotatedTag, false); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Get an annotated tag. * * @param {string} project - Project ID or project name * @param {string} repositoryId - ID or name of the repository. * @param {string} objectId - ObjectId (Sha1Id) of tag to get. */ getAnnotatedTag(project, repositoryId, objectId) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, repositoryId: repositoryId, objectId: objectId }; try { let verData = yield this.vsoClient.getVersioningData("6.0-preview.1", "git", "5e8a8081-3851-4626-b677-9891cc04102e", routeValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.get(url, options); let ret = this.formatResponse(res.result, GitInterfaces.TypeInfo.GitAnnotatedTag, false); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Get a single blob. * * @param {string} repositoryId - The name or ID of the repository. * @param {string} sha1 - SHA1 hash of the file. You can get the SHA1 of a file using the "Git/Items/Get Item" endpoint. * @param {string} project - Project ID or project name * @param {boolean} download - If true, prompt for a download rather than rendering in a browser. Note: this value defaults to true if $format is zip * @param {string} fileName - Provide a fileName to use for a download. * @param {boolean} resolveLfs - If true, try to resolve a blob to its LFS contents, if it's an LFS pointer file. Only compatible with octet-stream Accept headers or $format types */ getBlob(repositoryId, sha1, project, download, fileName, resolveLfs) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, repositoryId: repositoryId, sha1: sha1 }; let queryValues = { download: download, fileName: fileName, resolveLfs: resolveLfs, }; try { let verData = yield this.vsoClient.getVersioningData("6.0-preview.1", "git", "7b28e929-2c99-405d-9c5c-6167a06e6816", routeValues, queryValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.get(url, options); let ret = this.formatResponse(res.result, null, false); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Get a single blob. * * @param {string} repositoryId - The name or ID of the repository. * @param {string} sha1 - SHA1 hash of the file. You can get the SHA1 of a file using the "Git/Items/Get Item" endpoint. * @param {string} project - Project ID or project name * @param {boolean} download - If true, prompt for a download rather than rendering in a browser. Note: this value defaults to true if $format is zip * @param {string} fileName - Provide a fileName to use for a download. * @param {boolean} resolveLfs - If true, try to resolve a blob to its LFS contents, if it's an LFS pointer file. Only compatible with octet-stream Accept headers or $format types */ getBlobContent(repositoryId, sha1, project, download, fileName, resolveLfs) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, repositoryId: repositoryId, sha1: sha1 }; let queryValues = { download: download, fileName: fileName, resolveLfs: resolveLfs, }; try { let verData = yield this.vsoClient.getVersioningData("6.0-preview.1", "git", "7b28e929-2c99-405d-9c5c-6167a06e6816", routeValues, queryValues); let url = verData.requestUrl; let apiVersion = verData.apiVersion; let accept = this.createAcceptHeader("application/octet-stream", apiVersion); resolve((yield this.http.get(url, { "Accept": accept })).message); } catch (err) { reject(err); } })); }); } /** * Gets one or more blobs in a zip file download. * * @param {string[]} blobIds - Blob IDs (SHA1 hashes) to be returned in the zip file. * @param {string} repositoryId - The name or ID of the repository. * @param {string} project - Project ID or project name * @param {string} filename */ getBlobsZip(blobIds, repositoryId, project, filename) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, repositoryId: repositoryId }; let queryValues = { filename: filename, }; try { let verData = yield this.vsoClient.getVersioningData("6.0-preview.1", "git", "7b28e929-2c99-405d-9c5c-6167a06e6816", routeValues, queryValues); let url = verData.requestUrl; let apiVersion = verData.apiVersion; let accept = this.createAcceptHeader("application/zip", apiVersion); resolve((yield this.http.get(url, { "Accept": accept })).message); } catch (err) { reject(err); } })); }); } /** * Get a single blob. * * @param {string} repositoryId - The name or ID of the repository. * @param {string} sha1 - SHA1 hash of the file. You can get the SHA1 of a file using the "Git/Items/Get Item" endpoint. * @param {string} project - Project ID or project name * @param {boolean} download - If true, prompt for a download rather than rendering in a browser. Note: this value defaults to true if $format is zip * @param {string} fileName - Provide a fileName to use for a download. * @param {boolean} resolveLfs - If true, try to resolve a blob to its LFS contents, if it's an LFS pointer file. Only compatible with octet-stream Accept headers or $format types */ getBlobZip(repositoryId, sha1, project, download, fileName, resolveLfs) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, repositoryId: repositoryId, sha1: sha1 }; let queryValues = { download: download, fileName: fileName, resolveLfs: resolveLfs, }; try { let verData = yield this.vsoClient.getVersioningData("6.0-preview.1", "git", "7b28e929-2c99-405d-9c5c-6167a06e6816", routeValues, queryValues); let url = verData.requestUrl; let apiVersion = verData.apiVersion; let accept = this.createAcceptHeader("application/zip", apiVersion); resolve((yield this.http.get(url, { "Accept": accept })).message); } catch (err) { reject(err); } })); }); } /** * Retrieve statistics about a single branch. * * @param {string} repositoryId - The name or ID of the repository. * @param {string} name - Name of the branch. * @param {string} project - Project ID or project name * @param {GitInterfaces.GitVersionDescriptor} baseVersionDescriptor - Identifies the commit or branch to use as the base. */ getBranch(repositoryId, name, project, baseVersionDescriptor) { return __awaiter(this, void 0, void 0, function* () { if (name == null) { throw new TypeError('name can not be null or undefined'); } return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, repositoryId: repositoryId }; let queryValues = { name: name, baseVersionDescriptor: baseVersionDescriptor, }; try { let verData = yield this.vsoClient.getVersioningData("6.0-preview.1", "git", "d5b216de-d8d5-4d32-ae76-51df755b16d3", routeValues, queryValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.get(url, options); let ret = this.formatResponse(res.result, GitInterfaces.TypeInfo.GitBranchStats, false); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Retrieve statistics about all branches within a repository. * * @param {string} repositoryId - The name or ID of the repository. * @param {string} project - Project ID or project name * @param {GitInterfaces.GitVersionDescriptor} baseVersionDescriptor - Identifies the commit or branch to use as the base. */ getBranches(repositoryId, project, baseVersionDescriptor) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, repositoryId: repositoryId }; let queryValues = { baseVersionDescriptor: baseVersionDescriptor, }; try { let verData = yield this.vsoClient.getVersioningData("6.0-preview.1", "git", "d5b216de-d8d5-4d32-ae76-51df755b16d3", routeValues, queryValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.get(url, options); let ret = this.formatResponse(res.result, GitInterfaces.TypeInfo.GitBranchStats, true); resolve(ret); } catch (err) { reject(err); } })); }); } /** * @param {GitInterfaces.GitQueryBranchStatsCriteria} searchCriteria * @param {string} repositoryId * @param {string} project - Project ID or project name */ getBranchStatsBatch(searchCriteria, repositoryId, project) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, repositoryId: repositoryId }; try { let verData = yield this.vsoClient.getVersioningData("6.0-preview.1", "git", "d5b216de-d8d5-4d32-ae76-51df755b16d3", routeValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.create(url, searchCriteria, options); let ret = this.formatResponse(res.result, GitInterfaces.TypeInfo.GitBranchStats, true); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Retrieve changes for a particular commit. * * @param {string} commitId - The id of the commit. * @param {string} repositoryId - The id or friendly name of the repository. To use the friendly name, projectId must also be specified. * @param {string} project - Project ID or project name * @param {number} top - The maximum number of changes to return. * @param {number} skip - The number of changes to skip. */ getChanges(commitId, repositoryId, project, top, skip) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, commitId: commitId, repositoryId: repositoryId }; let queryValues = { top: top, skip: skip, }; try { let verData = yield this.vsoClient.getVersioningData("6.0-preview.1", "git", "5bf884f5-3e07-42e9-afb8-1b872267bf16", routeValues, queryValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.get(url, options); let ret = this.formatResponse(res.result, GitInterfaces.TypeInfo.GitCommitChanges, false); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Retrieve one conflict for a cherry pick by ID * * @param {string} repositoryId * @param {number} cherryPickId * @param {number} conflictId * @param {string} project - Project ID or project name */ getCherryPickConflict(repositoryId, cherryPickId, conflictId, project) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, repositoryId: repositoryId, cherryPickId: cherryPickId, conflictId: conflictId }; try { let verData = yield this.vsoClient.getVersioningData("6.0-preview.1", "git", "1fe5aab2-d4c0-4b2f-a030-f3831e7aca26", routeValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.get(url, options); let ret = this.formatResponse(res.result, GitInterfaces.TypeInfo.GitConflict, false); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Retrieve all conflicts for a cherry pick * * @param {string} repositoryId * @param {number} cherryPickId * @param {string} project - Project ID or project name * @param {string} continuationToken * @param {number} top * @param {boolean} excludeResolved * @param {boolean} onlyResolved * @param {boolean} includeObsolete */ getCherryPickConflicts(repositoryId, cherryPickId, project, continuationToken, top, excludeResolved, onlyResolved, includeObsolete) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, repositoryId: repositoryId, cherryPickId: cherryPickId }; let queryValues = { continuationToken: continuationToken, '$top': top, excludeResolved: excludeResolved, onlyResolved: onlyResolved, includeObsolete: includeObsolete, }; try { let verData = yield this.vsoClient.getVersioningData("6.0-preview.1", "git", "1fe5aab2-d4c0-4b2f-a030-f3831e7aca26", routeValues, queryValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.get(url, options); let ret = this.formatResponse(res.result, GitInterfaces.TypeInfo.GitConflict, true); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Update merge conflict resolution * * @param {GitInterfaces.GitConflict} conflict * @param {string} repositoryId * @param {number} cherryPickId * @param {number} conflictId * @param {string} project - Project ID or project name */ updateCherryPickConflict(conflict, repositoryId, cherryPickId, conflictId, project) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, repositoryId: repositoryId, cherryPickId: cherryPickId, conflictId: conflictId }; try { let verData = yield this.vsoClient.getVersioningData("6.0-preview.1", "git", "1fe5aab2-d4c0-4b2f-a030-f3831e7aca26", routeValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.update(url, conflict, options); let ret = this.formatResponse(res.result, GitInterfaces.TypeInfo.GitConflict, false); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Update multiple merge conflict resolutions * * @param {GitInterfaces.GitConflict[]} conflictUpdates * @param {string} repositoryId * @param {number} cherryPickId * @param {string} project - Project ID or project name */ updateCherryPickConflicts(conflictUpdates, repositoryId, cherryPickId, project) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, repositoryId: repositoryId, cherryPickId: cherryPickId }; try { let verData = yield this.vsoClient.getVersioningData("6.0-preview.1", "git", "1fe5aab2-d4c0-4b2f-a030-f3831e7aca26", routeValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.update(url, conflictUpdates, options); let ret = this.formatResponse(res.result, GitInterfaces.TypeInfo.GitConflictUpdateResult, true); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Given a commitId, returns a list of commits that are in the same cherry-pick family. * * @param {string} repositoryNameOrId * @param {string} commitId * @param {string} project - Project ID or project name * @param {boolean} includeLinks */ getCherryPickRelationships(repositoryNameOrId, commitId, project, includeLinks) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, repositoryNameOrId: repositoryNameOrId, commitId: commitId }; let queryValues = { includeLinks: includeLinks, }; try { let verData = yield this.vsoClient.getVersioningData("6.0-preview.1", "git", "8af142a4-27c2-4168-9e82-46b8629aaa0d", routeValues, queryValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.get(url, options); let ret = this.formatResponse(res.result, GitInterfaces.TypeInfo.GitCommitRef, true); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Cherry pick a specific commit or commits that are associated to a pull request into a new branch. * * @param {GitInterfaces.GitAsyncRefOperationParameters} cherryPickToCreate * @param {string} project - Project ID or project name * @param {string} repositoryId - ID of the repository. */ createCherryPick(cherryPickToCreate, project, repositoryId) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, repositoryId: repositoryId }; try { let verData = yield this.vsoClient.getVersioningData("6.0-preview.1", "git", "033bad68-9a14-43d1-90e0-59cb8856fef6", routeValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.create(url, cherryPickToCreate, options); let ret = this.formatResponse(res.result, GitInterfaces.TypeInfo.GitCherryPick, false); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Retrieve information about a cherry pick by cherry pick Id. * * @param {string} project - Project ID or project name * @param {number} cherryPickId - ID of the cherry pick. * @param {string} repositoryId - ID of the repository. */ getCherryPick(project, cherryPickId, repositoryId) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, cherryPickId: cherryPickId, repositoryId: repositoryId }; try { let verData = yield this.vsoClient.getVersioningData("6.0-preview.1", "git", "033bad68-9a14-43d1-90e0-59cb8856fef6", routeValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.get(url, options); let ret = this.formatResponse(res.result, GitInterfaces.TypeInfo.GitCherryPick, false); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Retrieve information about a cherry pick for a specific branch. * * @param {string} project - Project ID or project name * @param {string} repositoryId - ID of the repository. * @param {string} refName - The GitAsyncRefOperationParameters generatedRefName used for the cherry pick operation. */ getCherryPickForRefName(project, repositoryId, refName) { return __awaiter(this, void 0, void 0, function* () { if (refName == null) { throw new TypeError('refName can not be null or undefined'); } return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, repositoryId: repositoryId }; let queryValues = { refName: refName, }; try { let verData = yield this.vsoClient.getVersioningData("6.0-preview.1", "git", "033bad68-9a14-43d1-90e0-59cb8856fef6", routeValues, queryValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.get(url, options); let ret = this.formatResponse(res.result, GitInterfaces.TypeInfo.GitCherryPick, false); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Find the closest common commit (the merge base) between base and target commits, and get the diff between either the base and target commits or common and target commits. * * @param {string} repositoryId - The name or ID of the repository. * @param {string} project - Project ID or project name * @param {boolean} diffCommonCommit - If true, diff between common and target commits. If false, diff between base and target commits. * @param {number} top - Maximum number of changes to return. Defaults to 100. * @param {number} skip - Number of changes to skip * @param {GitInterfaces.GitBaseVersionDescriptor} baseVersionDescriptor - Descriptor for base commit. * @param {GitInterfaces.GitTargetVersionDescriptor} targetVersionDescriptor - Descriptor for target commit. */ getCommitDiffs(repositoryId, project, diffCommonCommit, top, skip, baseVersionDescriptor, targetVersionDescriptor) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, repositoryId: repositoryId }; let queryValues = { diffCommonCommit: diffCommonCommit, '$top': top, '$skip': skip, }; if (baseVersionDescriptor) { queryValues.baseVersionType = baseVersionDescriptor.versionType; queryValues.baseVersion = baseVersionDescriptor.version; queryValues.baseVersionOptions = baseVersionDescriptor.versionOptions; } if (targetVersionDescriptor) { queryValues.targetVersionType = targetVersionDescriptor.versionType; queryValues.targetVersion = targetVersionDescriptor.version; queryValues.targetVersionOptions = targetVersionDescriptor.versionOptions; } try { let verData = yield this.vsoClient.getVersioningData("6.0-preview.1", "git", "615588d5-c0c7-4b88-88f8-e625306446e8", routeValues, queryValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.get(url, options); let ret = this.formatResponse(res.result, GitInterfaces.TypeInfo.GitCommitDiffs, false); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Retrieve a particular commit. * * @param {string} commitId - The id of the commit. * @param {string} repositoryId - The id or friendly name of the repository. To use the friendly name, projectId must also be specified. * @param {string} project - Project ID or project name * @param {number} changeCount - The number of changes to include in the result. */ getCommit(commitId, repositoryId, project, changeCount) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, commitId: commitId, repositoryId: repositoryId }; let queryValues = { changeCount: changeCount, }; try { let verData = yield this.vsoClient.getVersioningData("6.0-preview.1", "git", "c2570c3b-5b3f-41b8-98bf-5407bfde8d58", routeValues, queryValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.get(url, options); let ret = this.formatResponse(res.result, GitInterfaces.TypeInfo.GitCommit, false); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Retrieve git commits for a project * * @param {string} repositoryId - The id or friendly name of the repository. To use the friendly name, projectId must also be specified. * @param {GitInterfaces.GitQueryCommitsCriteria} searchCriteria * @param {string} project - Project ID or project name * @param {number} skip * @param {number} top */ getCommits(repositoryId, searchCriteria, project, skip, top) { return __awaiter(this, void 0, void 0, function* () { if (searchCriteria == null) { throw new TypeError('searchCriteria can not be null or undefined'); } return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, repositoryId: repositoryId }; let queryValues = { searchCriteria: searchCriteria, '$skip': skip, '$top': top, }; try { let verData = yield this.vsoClient.getVersioningData("6.0-preview.1", "git", "c2570c3b-5b3f-41b8-98bf-5407bfde8d58", routeValues, queryValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.get(url, options); let ret = this.formatResponse(res.result, GitInterfaces.TypeInfo.GitCommitRef, true); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Retrieve a list of commits associated with a particular push. * * @param {string} repositoryId - The id or friendly name of the repository. To use the friendly name, projectId must also be specified. * @param {number} pushId - The id of the push. * @param {string} project - Project ID or project name * @param {number} top - The maximum number of commits to return ("get the top x commits"). * @param {number} skip - The number of commits to skip. * @param {boolean} includeLinks - Set to false to avoid including REST Url links for resources. Defaults to true. */ getPushCommits(repositoryId, pushId, project, top, skip, includeLinks) { return __awaiter(this, void 0, void 0, function* () { if (pushId == null) { throw new TypeError('pushId can not be null or undefined'); } return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, repositoryId: repositoryId }; let queryValues = { pushId: pushId, top: top, skip: skip, includeLinks: includeLinks, }; try { let verData = yield this.vsoClient.getVersioningData("6.0-preview.1", "git", "c2570c3b-5b3f-41b8-98bf-5407bfde8d58", routeValues, queryValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.get(url, options); let ret = this.formatResponse(res.result, GitInterfaces.TypeInfo.GitCommitRef, true); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Retrieve git commits for a project matching the search criteria * * @param {GitInterfaces.GitQueryCommitsCriteria} searchCriteria - Search options * @param {string} repositoryId - The name or ID of the repository. * @param {string} project - Project ID or project name * @param {number} skip - Number of commits to skip. * @param {number} top - Maximum number of commits to return. * @param {boolean} includeStatuses - True to include additional commit status information. */ getCommitsBatch(searchCriteria, repositoryId, project, skip, top, includeStatuses) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, repositoryId: repositoryId }; let queryValues = { '$skip': skip, '$top': top, includeStatuses: includeStatuses, }; try { let verData = yield this.vsoClient.getVersioningData("6.0-preview.1", "git", "6400dfb2-0bcb-462b-b992-5a57f8f1416c", routeValues, queryValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.create(url, searchCriteria, options); let ret = this.formatResponse(res.result, GitInterfaces.TypeInfo.GitCommitRef, true); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Retrieve deleted git repositories. * * @param {string} project - Project ID or project name */ getDeletedRepositories(project) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project }; try { let verData = yield this.vsoClient.getVersioningData("6.0-preview.1", "git", "2b6869c4-cb25-42b5-b7a3-0d3e6be0a11a", routeValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.get(url, options); let ret = this.formatResponse(res.result, GitInterfaces.TypeInfo.GitDeletedRepository, true); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Get the file diffs for each of the specified files * * @param {GitInterfaces.FileDiffsCriteria} fileDiffsCriteria - List of file parameters objects * @param {string} project - Project ID or project name * @param {string} repositoryId - The name or ID of the repository */ getFileDiffs(fileDiffsCriteria, project, repositoryId) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, repositoryId: repositoryId }; try { let verData = yield this.vsoClient.getVersioningData("6.0-preview.1", "git", "c4c5a7e6-e9f3-4730-a92b-84baacff694b", routeValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.create(url, fileDiffsCriteria, options); let ret = this.formatResponse(res.result, GitInterfaces.TypeInfo.FileDiff, true); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Retrieve all forks of a repository in the collection. * * @param {string} repositoryNameOrId - The name or ID of the repository. * @param {string} collectionId - Team project collection ID. * @param {string} project - Project ID or project name * @param {boolean} includeLinks - True to include links. */ getForks(repositoryNameOrId, collectionId, project, includeLinks) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, repositoryNameOrId: repositoryNameOrId, collectionId: collectionId }; let queryValues = { includeLinks: includeLinks, }; try { let verData = yield this.vsoClient.getVersioningData("6.0-preview.1", "git", "158c0340-bf6f-489c-9625-d572a1480d57", routeValues, queryValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.get(url, options); let ret = this.formatResponse(res.result, GitInterfaces.TypeInfo.GitRepositoryRef, true); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Request that another repository's refs be fetched into this one. It syncs two existing forks. To create a fork, please see the <a href="https://docs.microsoft.com/en-us/rest/api/vsts/git/repositories/create?view=azure-devops-rest-5.1"> repositories endpoint</a> * * @param {GitInterfaces.GitForkSyncRequestParameters} syncParams - Source repository and ref mapping. * @param {string} repositoryNameOrId - The name or ID of the repository. * @param {string} project - Project ID or project name * @param {boolean} includeLinks - True to include links */ createForkSyncRequest(syncParams, repositoryNameOrId, project, includeLinks) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, repositoryNameOrId: repositoryNameOrId }; let queryValues = { includeLinks: includeLinks, }; try { let verData = yield this.vsoClient.getVersioningData("6.0-preview.1", "git", "1703f858-b9d1-46af-ab62-483e9e1055b5", routeValues, queryValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.create(url, syncParams, options); let ret = this.formatResponse(res.result, GitInterfaces.TypeInfo.GitForkSyncRequest, false); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Get a specific fork sync operation's details. * * @param {string} repositoryNameOrId - The name or ID of the repository. * @param {number} forkSyncOperationId - OperationId of the sync request. * @param {string} project - Project ID or project name * @param {boolean} includeLinks - True to include links. */ getForkSyncRequest(repositoryNameOrId, forkSyncOperationId, project, includeLinks) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, repositoryNameOrId: repositoryNameOrId, forkSyncOperationId: forkSyncOperationId }; let queryValues = { includeLinks: includeLinks, }; try { let verData = yield this.vsoClient.getVersioningData("6.0-preview.1", "git", "1703f858-b9d1-46af-ab62-483e9e1055b5", routeValues, queryValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.get(url, options); let ret = this.formatResponse(res.result, GitInterfaces.TypeInfo.GitForkSyncRequest, false); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Retrieve all requested fork sync operations on this repository. * * @param {string} repositoryNameOrId - The name or ID of the repository. * @param {string} project - Project ID or project name * @param {boolean} includeAbandoned - True to include abandoned requests. * @param {boolean} includeLinks - True to include links. */ getForkSyncRequests(repositoryNameOrId, project, includeAbandoned, includeLinks) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, repositoryNameOrId: repositoryNameOrId }; let queryValues = { includeAbandoned: includeAbandoned, includeLinks: includeLinks, }; try { let verData = yield this.vsoClient.getVersioningData("6.0-preview.1", "git", "1703f858-b9d1-46af-ab62-483e9e1055b5", routeValues, queryValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.get(url, options); let ret = this.formatResponse(res.result, GitInterfaces.TypeInfo.GitForkSyncRequest, true); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Create an import request. * * @param {GitInterfaces.GitImportRequest} importRequest - The import request to create. * @param {string} project - Project ID or project name * @param {string} repositoryId - The name or ID of the repository. */ createImportRequest(importRequest, project, rep