Items - Get
获取单个项的项元数据和/或内容。 下载参数是指示内容应作为下载提供,还是只是作为响应中的流发送。 不适用于压缩内容,该内容始终作为下载返回。
GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/items?path={path}&api-version=7.1
GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/items?path={path}&scopePath={scopePath}&recursionLevel={recursionLevel}&includeContentMetadata={includeContentMetadata}&latestProcessedChange={latestProcessedChange}&download={download}&$format={$format}&versionDescriptor.version={versionDescriptor.version}&versionDescriptor.versionOptions={versionDescriptor.versionOptions}&versionDescriptor.versionType={versionDescriptor.versionType}&includeContent={includeContent}&resolveLfs={resolveLfs}&sanitize={sanitize}&api-version=7.1
URI 参数
名称 | 在 | 必需 | 类型 | 说明 |
---|---|---|---|---|
organization
|
path | True |
string |
Azure DevOps 组织的名称。 |
repository
|
path | True |
string |
存储库的名称或 ID。 |
project
|
path |
string |
项目 ID 或项目名称 |
|
api-version
|
query | True |
string |
要使用的 API 版本。 这应设置为“7.1”才能使用此版本的 API。 |
path
|
query | True |
string |
项路径。 |
$format
|
query |
string |
如果指定,这将替代 HTTP Accept 请求标头以返回“json”或“zip”。 如果指定了$format,则 API 版本还应指定为查询参数。 |
|
download
|
query |
boolean |
设置为 true 以将响应下载为文件。 默认值为 false。 |
|
include
|
query |
boolean |
设置为 true 以在请求 json 时包含项内容。 默认值为 false。 |
|
include
|
query |
boolean |
设置为 true 以包含内容元数据。 默认值为 false。 |
|
latest
|
query |
boolean |
设置为 true 以包含最新更改。 默认值为 false。 |
|
recursion
|
query |
此请求的递归级别。 默认值为“none”,无递归。 |
||
resolve
|
query |
boolean |
设置为 true 以解析 Git LFS 指针文件以从 Git LFS 返回实际内容。 默认值为 false。 |
|
sanitize
|
query |
boolean |
设置为 true 以清理 svg 文件并将其作为图像返回。 仅当请求 svg 文件时才有用。 默认值为 false。 |
|
scope
|
query |
string |
路径范围。 默认值为 null。 |
|
version
|
query |
string |
版本字符串标识符(标记/分支的名称,提交 SHA1) |
|
version
|
query |
版本选项 - 指定版本的其他修饰符(例如上一个) |
||
version
|
query |
版本类型(分支、标记或提交)。 确定如何解释 ID |
响应
名称 | 类型 | 说明 |
---|---|---|
200 OK |
成功作 Media Types: "application/zip", "text/plain", "application/octet-stream", "application/json" |
安全性
oauth2
类型:
oauth2
流向:
accessCode
授权 URL:
https://app.vssps.visualstudio.com/oauth2/authorize&response_type=Assertion
令牌 URL:
https://app.vssps.visualstudio.com/oauth2/token?client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer&grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer
作用域
名称 | 说明 |
---|---|
vso.code | 授予读取有关提交、更改集、分支和其他版本控制项目的源代码和元数据的能力。 此外,还可以通过服务挂钩搜索代码并获取有关版本控制事件的通知。 |
示例
Download |
Get metadata |
Download
示例请求
GET https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/items?scopePath=/MyWebSite/MyWebSite/Views/Home/_Home.cshtml&download=true&api-version=7.1
示例响应
{
"count": 1,
"value": [
{
"objectId": "61a86fdaa79e5c6f5fb6e4026508489feb6ed92c",
"gitObjectType": "blob",
"commitId": "23d0bc5b128a10056dc68afece360d8a0fabb014",
"path": "/MyWebSite/MyWebSite/Views/Home/_Home.cshtml",
"url": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/items/MyWebSite/MyWebSite/Views/Home/_Home.cshtml?versionType=Branch&versionOptions=None"
}
]
}
Get metadata
示例请求
GET https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/items?scopePath=/MyWebSite/MyWebSite/Views/Home/_Home.cshtml&api-version=7.1
示例响应
{
"count": 1,
"value": [
{
"objectId": "61a86fdaa79e5c6f5fb6e4026508489feb6ed92c",
"gitObjectType": "blob",
"commitId": "23d0bc5b128a10056dc68afece360d8a0fabb014",
"path": "/MyWebSite/MyWebSite/Views/Home/_Home.cshtml",
"url": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/items/MyWebSite/MyWebSite/Views/Home/_Home.cshtml?versionType=Branch&versionOptions=None"
}
]
}
定义
名称 | 说明 |
---|---|
Change |
|
File |
|
Git |
|
Git |
提供描述 Git 提交和关联元数据的属性。 |
Git |
|
Git |
对象类型(提交、树、Blob、标记) |
Git |
|
Git |
此类包含发布状态的服务/扩展的元数据。 |
Git |
唯一标识状态的状态上下文。 |
Git |
状态。 |
Git |
|
Git |
Git作的用户信息和日期。 |
Git |
版本选项 - 指定版本的其他修饰符(例如上一个) |
Git |
版本类型(分支、标记或提交)。 确定如何解释 ID |
Identity |
|
Item |
|
Item |
|
Reference |
表示 REST 引用链接集合的类。 |
Resource |
|
Version |
对项所做的更改的类型。 |
Version |
指定是包括子级(OneLevel)、所有后代(Full)还是 None |
ChangeCountDictionary
FileContentMetadata
名称 | 类型 | 说明 |
---|---|---|
contentType |
string |
|
encoding |
integer (int32) |
|
extension |
string |
|
fileName |
string |
|
isBinary |
boolean |
|
isImage |
boolean |
|
vsLink |
string |
GitChange
名称 | 类型 | 说明 |
---|---|---|
changeId |
integer (int32) |
更改组中更改的 ID。 |
changeType |
对项所做的更改的类型。 |
|
item |
string (T) |
当前版本。 |
newContent |
更改后项的内容。 |
|
newContentTemplate |
推送新更改时要使用的新内容模板。 |
|
originalPath |
string |
项目的原始路径(如果与当前路径不同)。 |
sourceServerItem |
string |
服务器上的项的路径。 |
url |
string |
用于检索项的 URL。 |
GitCommitRef
提供描述 Git 提交和关联元数据的属性。
名称 | 类型 | 说明 |
---|---|---|
_links |
相关 REST 引用链接的集合。 |
|
author |
提交作者。 |
|
changeCounts |
提交中包含的更改类型(编辑、删除等)的计数。 |
|
changes |
提交中包含的更改的枚举。 |
|
comment |
string |
提交注释或消息。 |
commentTruncated |
boolean |
指示注释是否从完整的 Git 提交注释消息中截断。 |
commitId |
string |
提交的 ID (SHA-1)。 |
commitTooManyChanges |
boolean |
指示提交包含过多的更改无法显示 |
committer |
提交者。 |
|
parents |
string[] |
此提交的父提交 ID 的枚举。 |
push |
与此提交关联的推送。 |
|
remoteUrl |
string |
提交远程 URL 路径。 |
statuses |
服务和扩展中的状态元数据列表,这些元数据可能会将其他信息与提交相关联。 |
|
url |
string |
此资源的 REST URL。 |
workItems |
与此提交关联的工作项列表。 |
GitItem
名称 | 类型 | 说明 |
---|---|---|
_links |
表示 REST 引用链接集合的类。 |
|
commitId |
string |
已提取提交项的 SHA1 |
content |
string |
|
contentMetadata | ||
gitObjectType |
对象类型(提交、树、Blob、标记、...) |
|
isFolder |
boolean |
|
isSymLink |
boolean |
|
latestProcessedChange |
浅表 ref 提交上次更改此项目仅当请求 latestProcessedChange 时填充的可能不准确(如果尚未缓存最新更改) |
|
objectId |
string |
Git 对象 ID |
originalObjectId |
string |
Git 对象 ID |
path |
string |
|
url |
string |
GitObjectType
对象类型(提交、树、Blob、标记)
值 | 说明 |
---|---|
bad | |
blob | |
commit | |
ext2 | |
ofsDelta | |
refDelta | |
tag | |
tree |
GitPushRef
名称 | 类型 | 说明 |
---|---|---|
_links |
表示 REST 引用链接集合的类。 |
|
date |
string (date-time) |
|
pushId |
integer (int32) |
|
pushedBy | ||
url |
string |
GitStatus
此类包含发布状态的服务/扩展的元数据。
名称 | 类型 | 说明 |
---|---|---|
_links |
参考链接。 |
|
context |
状态的上下文。 |
|
createdBy |
创建状态的标识。 |
|
creationDate |
string (date-time) |
状态的创建日期和时间。 |
description |
string |
状态说明。 通常描述状态的当前状态。 |
id |
integer (int32) |
状态标识符。 |
state |
状态。 |
|
targetUrl |
string |
包含状态详细信息的 URL。 |
updatedDate |
string (date-time) |
状态的上次更新日期和时间。 |
GitStatusContext
唯一标识状态的状态上下文。
名称 | 类型 | 说明 |
---|---|---|
genre |
string |
状态的流派。 通常,生成状态的服务/工具的名称可以为空。 |
name |
string |
状态的名称标识符不能为 null 或为空。 |
GitStatusState
状态。
值 | 说明 |
---|---|
error |
状态,出现错误。 |
failed |
状态失败。 |
notApplicable |
状态不适用于目标对象。 |
notSet |
未设置状态。 默认状态。 |
pending |
状态挂起。 |
succeeded |
状态成功。 |
GitTemplate
名称 | 类型 | 说明 |
---|---|---|
name |
string |
模板的名称 |
type |
string |
模板的类型 |
GitUserDate
Git作的用户信息和日期。
名称 | 类型 | 说明 |
---|---|---|
date |
string (date-time) |
Git作的日期。 |
string |
执行 Git作的用户的电子邮件地址。 |
|
imageUrl |
string |
用户的头像的 URL。 |
name |
string |
执行 Git作的用户的名称。 |
GitVersionOptions
版本选项 - 指定版本的其他修饰符(例如上一个)
值 | 说明 |
---|---|
firstParent |
提交的第一个父级 (HEAD^) |
none |
未指定 |
previousChange |
提交在当前版本之前更改的项 |
GitVersionType
版本类型(分支、标记或提交)。 确定如何解释 ID
值 | 说明 |
---|---|
branch |
将版本解释为分支名称 |
commit |
将版本解释为提交 ID (SHA1) |
tag |
将版本解释为标记名称 |
IdentityRef
名称 | 类型 | 说明 |
---|---|---|
_links |
此字段包含有关图形主题的零个或多个有趣的链接。 可以调用这些链接以获取有关此图形主题的其他关系或更详细的信息。 |
|
descriptor |
string |
描述符是在系统运行时引用图形主题的主要方法。 此字段将唯一标识帐户和组织中的同一图形主题。 |
directoryAlias |
string |
已弃用 - 可以通过查询 IdentityRef“_links”字典的“self”条目中引用的 Graph 用户来检索 |
displayName |
string |
这是图形主题的非唯一显示名称。 若要更改此字段,必须在源提供程序中更改其值。 |
id |
string |
|
imageUrl |
string |
已弃用 - 在 IdentityRef“_links”字典的“虚拟形象”条目中可用 |
inactive |
boolean |
已弃用 - 可以通过查询 GraphUser“_links”字典的“membershipState”条目中引用的 Graph 成员身份状态来检索 |
isAadIdentity |
boolean |
已弃用 - 可以从描述符的主题类型推断(Descriptor.IsAadUserType/Descriptor.IsAadGroupType) |
isContainer |
boolean |
已弃用 - 可以从描述符的主题类型推断(描述符.IsGroupType) |
isDeletedInOrigin |
boolean |
|
profileUrl |
string |
已弃用 - 不在 ToIdentityRef 的大多数预先存在的实现中使用 |
uniqueName |
string |
已弃用 - 请改用 Domain+PrincipalName |
url |
string |
此 URL 是指向此图形主题的源资源的完整路由。 |
ItemContent
名称 | 类型 | 说明 |
---|---|---|
content |
string |
|
contentType |
ItemContentType
值 | 说明 |
---|---|
base64Encoded | |
rawText |
ReferenceLinks
表示 REST 引用链接集合的类。
名称 | 类型 | 说明 |
---|---|---|
links |
object |
链接的只读视图。 由于引用链接是只读的,因此我们只想将其公开为只读链接。 |
ResourceRef
名称 | 类型 | 说明 |
---|---|---|
id |
string |
|
url |
string |
VersionControlChangeType
对项所做的更改的类型。
值 | 说明 |
---|---|
add | |
all | |
branch | |
delete | |
edit | |
encoding | |
lock | |
merge | |
none | |
property | |
rename | |
rollback | |
sourceRename | |
targetRename | |
undelete |
VersionControlRecursionType
指定是包括子级(OneLevel)、所有后代(Full)还是 None
值 | 说明 |
---|---|
full |
返回指定项和所有后代 |
none |
仅返回指定的项。 |
oneLevel |
返回指定的项及其直接子项。 |
oneLevelPlusNestedEmptyFolders |
返回指定项及其直接子项,以及仅包含单个文件夹的嵌套子文件夹的递归链。 |