Last Update: 9/26/2016

GitHttpClient2_2

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()

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

Returns

createPullRequestReviewer()

Adds a reviewer to a git pull request

Syntax

 IPromise<Contracts.IdentityRefWithVote> createPullRequestReviewer(reviewer, repositoryId, pullRequestId, reviewerId, project)

Parameters

Returns

createPullRequestReviewers()

Adds reviewers to a git pull request

Syntax

 IPromise<Contracts.IdentityRefWithVote[]> createPullRequestReviewers(reviewers, repositoryId, pullRequestId, project)

Parameters

Returns

createPush()

Push changes to the repository.

Syntax

 IPromise<Contracts.GitPush> createPush(push, repositoryId, project)

Parameters

Returns

createRepository()

Create a git repository

Syntax

 IPromise<Contracts.GitRepository> createRepository(gitRepositoryToCreate, project)

Parameters

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

deleteRepository()

Delete a git repository

Syntax

 IPromise<void> deleteRepository(repositoryId, project)

Parameters

  • repositoryId: string.
  • project: string. Optional.

Returns

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

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

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

getBranch()

Retrieve statistics about a single branch.

Syntax

 IPromise<Contracts.GitBranchStats> getBranch(repositoryId, name, project, baseVersionDescriptor)

Parameters

  • repositoryId: string. Friendly name or guid of repository
  • name: string. Name of the branch
  • project: string. Optional. Project ID or project name
  • baseVersionDescriptor: 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 repository
  • project: string. Optional. Project ID or project name
  • baseVersionDescriptor: 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 name
  • top: 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 name
  • changeCount: 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 options
  • 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 name
  • skip: 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

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

Returns

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

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

Returns

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

Returns

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

Returns

getPullRequestsByProject()

Query pull requests by project

Syntax

 IPromise<Contracts.GitPullRequest[]> getPullRequestsByProject(project, searchCriteria, maxCommentLength, skip, top)

Parameters

Returns

getPullRequestWorkItems()

Retrieve a pull request work items

Syntax

 IPromise<Contracts.AssociatedWorkItem[]> getPullRequestWorkItems(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 name
  • includeCommits: 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 name
  • top: 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 name
  • skip: 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 name
  • filter: 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 name
  • includeLinks: 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

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 perform
  • 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 name
  • projectId: 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

Returns