Skip to content

Instantly share code, notes, and snippets.

@phun-ky
Last active October 17, 2022 11:02
Show Gist options
  • Save phun-ky/97bacd9f57e14acdaabecbdd03f13c5c to your computer and use it in GitHub Desktop.
Save phun-ky/97bacd9f57e14acdaabecbdd03f13c5c to your computer and use it in GitHub Desktop.
A workaround to get diffs between commits, related to: https://github.com/MicrosoftDocs/vsts-rest-api-specs/issues/20
/*
The url and approach was reverse engineered from the deploy view of VSTS
The important part here is the `start_commit`-id and the `stop_commit`-id.
*/
const postBody = {
context: {
properties: {
repositoryName: <repository>,
projectName: <project_name>,
searchCriteria: {
gitCommitLookupArguments: null,
gitHistoryQueryArguments: {
startFromVersion: {
versionOptions: 0,
versionType: 2,
version: <start_commit>
},
notInVersion: { versionOptions: 0, versionType: 2, version: <stop_commit> },
order: 0,
path: '',
historyMode: 0,
stopAtAdds: false,
author: null,
committer: null
},
gitArtifactsQueryArguments: null,
gitGraphQueryArguments: {
fetchGraph: false,
emptyLineLengthLimit: 20,
emptyLineLengthMultiplier: false,
order: 0
}
}
}
},
contributionIds: ['ms.vss-code-web.git-history-view-commits-data-provider']
};
fetch({
uri: 'https://<account>.visualstudio.com/_apis/Contribution/dataProviders/query/project/<project>?api-version=5.0-preview.1',
method: 'POST',
body: postBody,
json: true
}).auth(<username>, <personal_access_token>)
@idiotleon
Copy link

idiotleon commented Sep 26, 2018

How did you come up with such a solution?!!!
BTW, which pkg are "fetch" and "auth" in?
Which API is applied?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment