GitHttpClient2_2
Important
Disclaimer: This API is in private preview and subject to change. This API is in private preview and subject to change.
Module path: TFS/VersionControl/GitRestClient
Initialization sample
import RestClient = require("TFS/VersionControl/GitRestClient");
// Get an instance of the client
var client = RestClient.getClient();
// Call a method on the client
// e.g. client.getResource(...).then(...);
Methods
- createCommitStatus()
- createPullRequest()
- createPullRequestReviewer()
- createPullRequestReviewers()
- createPush()
- createRepository()
- deletePullRequestReviewer()
- deleteRepository()
- getBlob()
- getBlobContent()
- getBlobsZip()
- getBlobZip()
- getBranch()
- getBranches()
- getChanges()
- getCommit()
- getCommits()
- getCommitsBatch()
- getItem()
- getItemContent()
- getItems()
- getItemsBatch()
- getItemText()
- getItemZip()
- getPullRequest()
- getPullRequestCommits()
- getPullRequestReviewer()
- getPullRequestReviewers()
- getPullRequests()
- getPullRequestsByProject()
- getPullRequestWorkItemRefs()
- getPush()
- getPushCommits()
- getPushes()
- getRefs()
- getRepositories()
- getRepository()
- getStatuses()
- getSuggestions()
- getTree()
- getTreeZip()
- updatePullRequest()
- updateRefs()
- updateRepository()
createCommitStatus()
Syntax
IPromise<Contracts.GitStatus> createCommitStatus(gitCommitStatusToCreate, commitId, repositoryId, project)
Parameters
gitCommitStatusToCreate
: Contracts.GitStatus.commitId
: string.repositoryId
: string.project
: string. Optional.
Returns
createPullRequest()
Create a git pull request
Syntax
IPromise<Contracts.GitPullRequest> createPullRequest(gitPullRequestToCreate, repositoryId, project)
Parameters
gitPullRequestToCreate
: Contracts.GitPullRequest.repositoryId
: string.project
: string. Optional.
Returns
createPullRequestReviewer()
Adds a reviewer to a git pull request
Syntax
IPromise<Contracts.IdentityRefWithVote> createPullRequestReviewer(reviewer, repositoryId, pullRequestId, reviewerId, project)
Parameters
reviewer
: Contracts.IdentityRefWithVote.repositoryId
: string.pullRequestId
: number.reviewerId
: string.project
: string. Optional.
Returns
createPullRequestReviewers()
Adds reviewers to a git pull request
Syntax
IPromise<Contracts.IdentityRefWithVote[]> createPullRequestReviewers(reviewers, repositoryId, pullRequestId, project)
Parameters
reviewers
: VSS_Common_Contracts.IdentityRef[].repositoryId
: string.pullRequestId
: number.project
: string. Optional.
Returns
createPush()
Push changes to the repository.
Syntax
IPromise<Contracts.GitPush> createPush(push, repositoryId, project)
Parameters
push
: Contracts.GitPush.repositoryId
: string.project
: string. Optional.
Returns
createRepository()
Create a git repository
Syntax
IPromise<Contracts.GitRepository> createRepository(gitRepositoryToCreate, project)
Parameters
gitRepositoryToCreate
: Contracts.GitRepository.project
: string. Optional.
Returns
deletePullRequestReviewer()
Adds reviewers to a git pull request
Syntax
IPromise<void> deletePullRequestReviewer(repositoryId, pullRequestId, reviewerId, project)
Parameters
repositoryId
: string.pullRequestId
: number.reviewerId
: string.project
: string. Optional.
Returns
- IPromise<void>
deleteRepository()
Delete a git repository
Syntax
IPromise<void> deleteRepository(repositoryId, project)
Parameters
repositoryId
: string.project
: string. Optional.
Returns
- IPromise<void>
getBlob()
Gets a single blob.
Syntax
IPromise<Contracts.GitBlobRef> getBlob(repositoryId, sha1, project, download, fileName)
Parameters
repositoryId
: string.sha1
: string.project
: string. Optional.download
: boolean. Optional.fileName
: string. Optional.
Returns
getBlobContent()
Gets a single blob.
Syntax
IPromise<ArrayBuffer> getBlobContent(repositoryId, sha1, project, download, fileName)
Parameters
repositoryId
: string.sha1
: string.project
: string. Optional.download
: boolean. Optional.fileName
: string. Optional.
Returns
- IPromise<ArrayBuffer>
getBlobsZip()
Gets one or more blobs in a zip file download.
Syntax
IPromise<ArrayBuffer> getBlobsZip(blobIds, repositoryId, project, filename)
Parameters
blobIds
: string[].repositoryId
: string.project
: string. Optional.filename
: string. Optional.
Returns
- IPromise<ArrayBuffer>
getBlobZip()
Gets a single blob.
Syntax
IPromise<ArrayBuffer> getBlobZip(repositoryId, sha1, project, download, fileName)
Parameters
repositoryId
: string.sha1
: string.project
: string. Optional.download
: boolean. Optional.fileName
: string. Optional.
Returns
- IPromise<ArrayBuffer>
getBranch()
Retrieve statistics about a single branch.
Syntax
IPromise<Contracts.GitBranchStats> getBranch(repositoryId, name, project, baseVersionDescriptor)
Parameters
repositoryId
: string. Friendly name or guid of repositoryname
: string. Name of the branchproject
: string. Optional. Project ID or project namebaseVersionDescriptor
: Contracts.GitVersionDescriptor. Optional.
Returns
getBranches()
Retrieve statistics about all branches within a repository.
Syntax
IPromise<Contracts.GitBranchStats[]> getBranches(repositoryId, project, baseVersionDescriptor)
Parameters
repositoryId
: string. Friendly name or guid of repositoryproject
: string. Optional. Project ID or project namebaseVersionDescriptor
: Contracts.GitVersionDescriptor. Optional.
Returns
getChanges()
Retrieve changes for a particular commit.
Syntax
IPromise<Contracts.GitCommitChanges> getChanges(commitId, repositoryId, project, top, skip)
Parameters
commitId
: string. The ID of the commit.repositoryId
: string. The ID or friendly name of the repository. To use the friendly name, projectId must also be specified.project
: string. Optional. Project ID or project nametop
: number. Optional. The maximum number of changes to return.skip
: number. Optional. The number of changes to skip.
Returns
getCommit()
Retrieve a particular commit.
Syntax
IPromise<Contracts.GitCommit> getCommit(commitId, repositoryId, project, changeCount)
Parameters
commitId
: string. The ID of the commit.repositoryId
: string. The ID or friendly name of the repository. To use the friendly name, projectId must also be specified.project
: string. Optional. Project ID or project namechangeCount
: number. Optional. The number of changes to include in the result.
Returns
getCommits()
Retrieve git commits for a project
Syntax
IPromise<Contracts.GitCommitRef[]> getCommits(repositoryId, searchCriteria, project, skip, top)
Parameters
repositoryId
: string. The ID or friendly name of the repository. To use the friendly name, projectId must also be specified.searchCriteria
: Contracts.GitQueryCommitsCriteria.project
: string. Optional.skip
: number. Optional.top
: number. Optional.
Returns
getCommitsBatch()
Retrieve git commits for a project
Syntax
IPromise<Contracts.GitCommitRef[]> getCommitsBatch(searchCriteria, repositoryId, project, skip, top)
Parameters
searchCriteria
: Contracts.GitQueryCommitsCriteria. Search optionsrepositoryId
: string. The ID or friendly name of the repository. To use the friendly name, projectId must also be specified.project
: string. Optional. Project ID or project nameskip
: number. Optional.top
: number. Optional.
Returns
getItem()
Get Item Metadata and/or Content for a single item. The download parameter is to indicate whether the content should be available as a download or just sent as a stream in the response. Doesn't apply to zipped content which is always returned as a download.
Syntax
IPromise<Contracts.GitItem> getItem(repositoryId, path, project, scopePath, recursionLevel, includeContentMetadata, latestProcessedChange, download, versionDescriptor)
Parameters
repositoryId
: string.path
: string.project
: string. Optional.scopePath
: string. Optional.recursionLevel
: Contracts.VersionControlRecursionType. Optional.includeContentMetadata
: boolean. Optional.latestProcessedChange
: boolean. Optional.download
: boolean. Optional.versionDescriptor
: Contracts.GitVersionDescriptor. Optional.
Returns
getItemContent()
Get Item Metadata and/or Content for a single item. The download parameter is to indicate whether the content should be available as a download or just sent as a stream in the response. Doesn't apply to zipped content which is always returned as a download.
Syntax
IPromise<ArrayBuffer> getItemContent(repositoryId, path, project, scopePath, recursionLevel, includeContentMetadata, latestProcessedChange, download, versionDescriptor)
Parameters
repositoryId
: string.path
: string.project
: string. Optional.scopePath
: string. Optional.recursionLevel
: Contracts.VersionControlRecursionType. Optional.includeContentMetadata
: boolean. Optional.latestProcessedChange
: boolean. Optional.download
: boolean. Optional.versionDescriptor
: Contracts.GitVersionDescriptor. Optional.
Returns
- IPromise<ArrayBuffer>
getItems()
Get Item Metadata and/or Content for a collection of items. The download parameter is to indicate whether the content should be available as a download or just sent as a stream in the response. Doesn't apply to zipped content which is always returned as a download.
Syntax
IPromise<Contracts.GitItem[]> getItems(repositoryId, project, scopePath, recursionLevel, includeContentMetadata, latestProcessedChange, download, includeLinks, versionDescriptor)
Parameters
repositoryId
: string.project
: string. Optional.scopePath
: string. Optional.recursionLevel
: Contracts.VersionControlRecursionType. Optional.includeContentMetadata
: boolean. Optional.latestProcessedChange
: boolean. Optional.download
: boolean. Optional.includeLinks
: boolean. Optional.versionDescriptor
: Contracts.GitVersionDescriptor. Optional.
Returns
getItemsBatch()
Post for retrieving a creating a batch out of a set of items in a repo / project given a list of paths or a long path
Syntax
IPromise<Contracts.GitItem[][]> getItemsBatch(requestData, repositoryId, project)
Parameters
requestData
: Contracts.GitItemRequestData.repositoryId
: string.project
: string. Optional.
Returns
getItemText()
Get Item Metadata and/or Content for a single item. The download parameter is to indicate whether the content should be available as a download or just sent as a stream in the response. Doesn't apply to zipped content which is always returned as a download.
Syntax
IPromise<string> getItemText(repositoryId, path, project, scopePath, recursionLevel, includeContentMetadata, latestProcessedChange, download, versionDescriptor)
Parameters
repositoryId
: string.path
: string.project
: string. Optional.scopePath
: string. Optional.recursionLevel
: Contracts.VersionControlRecursionType. Optional.includeContentMetadata
: boolean. Optional.latestProcessedChange
: boolean. Optional.download
: boolean. Optional.versionDescriptor
: Contracts.GitVersionDescriptor. Optional.
Returns
- IPromise<string>
getItemZip()
Get Item Metadata and/or Content for a single item. The download parameter is to indicate whether the content should be available as a download or just sent as a stream in the response. Doesn't apply to zipped content which is always returned as a download.
Syntax
IPromise<ArrayBuffer> getItemZip(repositoryId, path, project, scopePath, recursionLevel, includeContentMetadata, latestProcessedChange, download, versionDescriptor)
Parameters
repositoryId
: string.path
: string.project
: string. Optional.scopePath
: string. Optional.recursionLevel
: Contracts.VersionControlRecursionType. Optional.includeContentMetadata
: boolean. Optional.latestProcessedChange
: boolean. Optional.download
: boolean. Optional.versionDescriptor
: Contracts.GitVersionDescriptor. Optional.
Returns
- IPromise<ArrayBuffer>
getPullRequest()
Retrieve a pull request
Syntax
IPromise<Contracts.GitPullRequest> getPullRequest(repositoryId, pullRequestId, project, maxCommentLength, skip, top, includeCommits, includeWorkItemRefs)
Parameters
repositoryId
: string.pullRequestId
: number.project
: string. Optional.maxCommentLength
: number. Optional.skip
: number. Optional.top
: number. Optional.includeCommits
: boolean. Optional.includeWorkItemRefs
: boolean. Optional.
Returns
getPullRequestCommits()
Retrieve pull request's commits
Syntax
IPromise<Contracts.GitCommitRef[]> getPullRequestCommits(repositoryId, pullRequestId, project)
Parameters
repositoryId
: string.pullRequestId
: number.project
: string. Optional.
Returns
getPullRequestReviewer()
Retrieve a reviewer from a pull request
Syntax
IPromise<Contracts.IdentityRefWithVote> getPullRequestReviewer(repositoryId, pullRequestId, reviewerId, project)
Parameters
repositoryId
: string.pullRequestId
: number.reviewerId
: string.project
: string. Optional.
Returns
getPullRequestReviewers()
Retrieve a pull request reviewers
Syntax
IPromise<Contracts.IdentityRefWithVote[]> getPullRequestReviewers(repositoryId, pullRequestId, project)
Parameters
repositoryId
: string.pullRequestId
: number.project
: string. Optional.
Returns
getPullRequests()
Query for pull requests
Syntax
IPromise<Contracts.GitPullRequest[]> getPullRequests(repositoryId, searchCriteria, project, maxCommentLength, skip, top)
Parameters
repositoryId
: string.searchCriteria
: Contracts.GitPullRequestSearchCriteria.project
: string. Optional.maxCommentLength
: number. Optional.skip
: number. Optional.top
: number. Optional.
Returns
getPullRequestsByProject()
Query pull requests by project
Syntax
IPromise<Contracts.GitPullRequest[]> getPullRequestsByProject(project, searchCriteria, maxCommentLength, skip, top)
Parameters
project
: string. Project ID or project namesearchCriteria
: Contracts.GitPullRequestSearchCriteria.maxCommentLength
: number. Optional.skip
: number. Optional.top
: number. Optional.
Returns
getPullRequestWorkItemRefs()
Retrieve a pull request work item refs
Syntax
IPromise<Contracts.AssociatedWorkItem[]> getPullRequestWorkItemRefs(repositoryId, pullRequestId, project, commitsTop, commitsSkip)
Parameters
repositoryId
: string.pullRequestId
: number.project
: string. Optional.commitsTop
: number. Optional.commitsSkip
: number. Optional.
Returns
getPush()
Retrieve a particular push.
Syntax
IPromise<Contracts.GitPush> getPush(repositoryId, pushId, project, includeCommits, includeRefUpdates)
Parameters
repositoryId
: string. The ID or friendly name of the repository. To use the friendly name, projectId must also be specified.pushId
: number. The ID of the push.project
: string. Optional. Project ID or project nameincludeCommits
: number. Optional. The number of commits to include in the result.includeRefUpdates
: boolean. Optional.
Returns
getPushCommits()
Retrieve a list of commits associated with a particular push.
Syntax
IPromise<Contracts.GitCommitRef[]> getPushCommits(repositoryId, pushId, project, top, skip, includeLinks)
Parameters
repositoryId
: string. The ID or friendly name of the repository. To use the friendly name, projectId must also be specified.pushId
: number. The ID of the push.project
: string. Optional. Project ID or project nametop
: number. Optional. The maximum number of commits to return ("get the top x commits").skip
: number. Optional. The number of commits to skip.includeLinks
: boolean. Optional.
Returns
getPushes()
Retrieves pushes associated with the specified repository.
Syntax
IPromise<Contracts.GitPush[]> getPushes(repositoryId, project, skip, top, searchCriteria)
Parameters
repositoryId
: string. The ID or friendly name of the repository. To use the friendly name, projectId must also be specified.project
: string. Optional. Project ID or project nameskip
: number. Optional.top
: number. Optional.searchCriteria
: Contracts.GitPushSearchCriteria. Optional.
Returns
getRefs()
Queries the provided repository for its refs and returns them.
Syntax
IPromise<Contracts.GitRef[]> getRefs(repositoryId, project, filter, includeLinks, includeStatuses)
Parameters
repositoryId
: string. The ID or friendly name of the repository. To use the friendly name, projectId must also be specified.project
: string. Optional. Project ID or project namefilter
: string. Optional. [optional] A filter to apply to the refs.includeLinks
: boolean. Optional. [optional] Specifies if referenceLinks should be included in the result. default is false.includeStatuses
: boolean. Optional. [optional] Includes the first 1000 statuses of the commits the refs are pointing at as well. default is false.
Returns
getRepositories()
Retrieve git repositories.
Syntax
IPromise<Contracts.GitRepository[]> getRepositories(project, includeLinks)
Parameters
project
: string. Optional. Project ID or project nameincludeLinks
: boolean. Optional.
Returns
getRepository()
Syntax
IPromise<Contracts.GitRepository> getRepository(repositoryId, project)
Parameters
repositoryId
: string.project
: string. Optional.
Returns
getStatuses()
Syntax
IPromise<Contracts.GitStatus[]> getStatuses(commitId, repositoryId, project, top, skip)
Parameters
commitId
: string.repositoryId
: string.project
: string. Optional.top
: number. Optional.skip
: number. Optional.
Returns
getSuggestions()
Retrieve a set of suggestions (including a pull request suggestion).
Syntax
IPromise<Contracts.GitSuggestion[]> getSuggestions(repositoryId, project)
Parameters
repositoryId
: string.project
: string. Optional.
Returns
getTree()
Syntax
IPromise<Contracts.GitTreeRef> getTree(repositoryId, sha1, project, projectId, recursive, fileName)
Parameters
repositoryId
: string.sha1
: string.project
: string. Optional.projectId
: string. Optional.recursive
: boolean. Optional.fileName
: string. Optional.
Returns
getTreeZip()
Syntax
IPromise<ArrayBuffer> getTreeZip(repositoryId, sha1, project, projectId, recursive, fileName)
Parameters
repositoryId
: string.sha1
: string.project
: string. Optional.projectId
: string. Optional.recursive
: boolean. Optional.fileName
: string. Optional.
Returns
- IPromise<ArrayBuffer>
updatePullRequest()
Updates a pull request
Syntax
IPromise<Contracts.GitPullRequest> updatePullRequest(gitPullRequestToUpdate, repositoryId, pullRequestId, project)
Parameters
gitPullRequestToUpdate
: Contracts.GitPullRequest.repositoryId
: string.pullRequestId
: number.project
: string. Optional.
Returns
updateRefs()
Creates or updates refs with the given information
Syntax
IPromise<Contracts.GitRefUpdateResult[]> updateRefs(refUpdates, repositoryId, project, projectId)
Parameters
refUpdates
: Contracts.GitRefUpdate[]. List of ref updates to attempt to performrepositoryId
: string. The ID or friendly name of the repository. To use the friendly name, projectId must also be specified.project
: string. Optional. Project ID or project nameprojectId
: string. Optional. The ID of the project.
Returns
updateRepository()
Updates the Git repository with the single populated change in the specified repository information.
Syntax
IPromise<Contracts.GitRepository> updateRepository(newRepositoryInfo, repositoryId, project)
Parameters
newRepositoryInfo
: Contracts.GitRepository.repositoryId
: string.project
: string. Optional.