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 參數
| 名稱 | 位於 | 必要 | 類型 | Description |
|---|---|---|---|---|
|
organization
|
path | True |
string |
Azure DevOps 組織的名稱。 |
|
repository
|
path | True |
string |
存放庫的名稱或標識碼。 |
|
project
|
path |
string |
項目識別碼或項目名稱 |
|
|
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 |
版本類型(分支、標記或認可)。 決定如何解譯標識碼 |
回應
| 名稱 | 類型 | Description |
|---|---|---|
| 200 OK |
成功作業 Media Types: "application/zip", "text/plain", "application/octet-stream", "application/json" |
安全性
oauth2
類型:
oauth2
Flow:
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
範圍
| 名稱 | Description |
|---|---|
| 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"
}
]
}
定義
| 名稱 | Description |
|---|---|
|
Change |
|
|
File |
|
|
Git |
|
|
Git |
提供描述 Git 認可和相關聯元數據的屬性。 |
|
Git |
|
|
Git |
物件類型(Commit、Tree、Blob、Tag) |
|
Git |
|
|
Git |
這個類別包含張貼狀態之服務/延伸模組的元數據。 |
|
Git |
可唯一識別狀態的狀態內容。 |
|
Git |
狀態的狀態。 |
|
Git |
|
|
Git |
Git 作業的使用者資訊和日期。 |
|
Git |
版本選項 - 指定版本的其他修飾詞 (例如上一個) |
|
Git |
版本類型(分支、標記或認可)。 決定如何解譯標識碼 |
|
Identity |
|
|
Item |
|
|
Item |
|
|
Reference |
表示 REST 參考連結集合的類別。 |
|
Resource |
|
|
Version |
對專案所做的變更類型。 |
|
Version |
指定是否要包含子系 (OneLevel)、所有子系 (Full) 或 None |
ChangeCountDictionary
FileContentMetadata
| 名稱 | 類型 | Description |
|---|---|---|
| contentType |
string |
|
| encoding |
integer (int32) |
|
| extension |
string |
|
| fileName |
string |
|
| isBinary |
boolean |
|
| isImage |
boolean |
|
| vsLink |
string |
GitChange
| 名稱 | 類型 | Description |
|---|---|---|
| changeId |
integer (int32) |
變更群組內的變更標識碼。 |
| changeType |
對專案所做的變更類型。 |
|
| item |
string (T) |
目前的版本。 |
| newContent |
變更之後的項目內容。 |
|
| newContentTemplate |
推送新變更時要使用的新內容範本。 |
|
| originalPath |
string |
如果與目前路徑不同,則為專案的原始路徑。 |
| sourceServerItem |
string |
伺服器上的項目路徑。 |
| url |
string |
要擷取專案的URL。 |
GitCommitRef
提供描述 Git 認可和相關聯元數據的屬性。
| 名稱 | 類型 | Description |
|---|---|---|
| _links |
相關 REST 參考連結的集合。 |
|
| author |
認可作者。 |
|
| changeCounts |
認可中包含的變更類型計數(編輯、刪除等)。 |
|
| changes |
認可隨附之變更的列舉。 |
|
| comment |
string |
認可的批註或訊息。 |
| commentTruncated |
boolean |
指出批註是否從完整的 Git 認可批注訊息中截斷。 |
| commitId |
string |
認可標識碼 (SHA-1)。 |
| commitTooManyChanges |
boolean |
表示認可包含太多變更無法顯示 |
| committer |
認可者。 |
|
| parents |
string[] |
這個認可之父認可標識碼的列舉。 |
| push |
與此認可相關聯的推送。 |
|
| remoteUrl |
string |
認可的遠端 URL 路徑。 |
| statuses |
服務與延伸模組的狀態元數據清單,這些元數據可能會使其他資訊與認可產生關聯。 |
|
| url |
string |
此資源的 REST URL。 |
| workItems |
與此認可相關聯的工作項目清單。 |
GitItem
| 名稱 | 類型 | Description |
|---|---|---|
| _links |
表示 REST 參考連結集合的類別。 |
|
| commitId |
string |
已擷取認可專案的SHA1 |
| content |
string |
|
| contentMetadata | ||
| gitObjectType |
物件類型(Commit、Tree、Blob、Tag、...) |
|
| isFolder |
boolean |
|
| isSymLink |
boolean |
|
| latestProcessedChange |
淺層 ref 認可上次變更此專案只有在要求 latestProcessedChange 時才會填入,如果尚未快取最新的變更,可能不正確 |
|
| objectId |
string |
Git 物件識別碼 |
| originalObjectId |
string |
Git 物件識別碼 |
| path |
string |
|
| url |
string |
GitObjectType
物件類型(Commit、Tree、Blob、Tag)
| 值 | Description |
|---|---|
| bad | |
| blob | |
| commit | |
| ext2 | |
| ofsDelta | |
| refDelta | |
| tag | |
| tree |
GitPushRef
| 名稱 | 類型 | Description |
|---|---|---|
| _links |
表示 REST 參考連結集合的類別。 |
|
| date |
string (date-time) |
|
| pushId |
integer (int32) |
|
| pushedBy | ||
| url |
string |
GitStatus
這個類別包含張貼狀態之服務/延伸模組的元數據。
| 名稱 | 類型 | Description |
|---|---|---|
| _links |
參考連結。 |
|
| context |
狀態的內容。 |
|
| createdBy |
建立狀態的身分識別。 |
|
| creationDate |
string (date-time) |
狀態的建立日期和時間。 |
| description |
string |
狀態描述。 通常描述狀態的目前狀態。 |
| id |
integer (int32) |
狀態標識碼。 |
| state |
狀態的狀態。 |
|
| targetUrl |
string |
具有狀態詳細數據的 URL。 |
| updatedDate |
string (date-time) |
狀態的上次更新日期和時間。 |
GitStatusContext
可唯一識別狀態的狀態內容。
| 名稱 | 類型 | Description |
|---|---|---|
| genre |
string |
狀態的內容類型。 通常產生狀態的服務/工具名稱可以是空的。 |
| name |
string |
狀態的名稱識別碼不可為 Null 或空白。 |
GitStatusState
狀態的狀態。
| 值 | Description |
|---|---|
| error |
發生錯誤的狀態。 |
| failed |
狀態失敗。 |
| notApplicable |
狀態不適用於目標物件。 |
| notSet |
未設定狀態。 默認狀態。 |
| pending |
狀態擱置中。 |
| succeeded |
狀態成功。 |
GitTemplate
| 名稱 | 類型 | Description |
|---|---|---|
| name |
string |
範本的名稱 |
| type |
string |
範本的類型 |
GitUserDate
Git 作業的使用者資訊和日期。
| 名稱 | 類型 | Description |
|---|---|---|
| date |
string (date-time) |
Git 作業的日期。 |
|
string |
執行 Git 作業之使用者的電子郵件位址。 |
|
| imageUrl |
string |
用戶的虛擬人偶 URL。 |
| name |
string |
執行 Git 作業的用戶名稱。 |
GitVersionOptions
版本選項 - 指定版本的其他修飾詞 (例如上一個)
| 值 | Description |
|---|---|
| firstParent |
認可的第一個父代 (HEAD^) |
| none |
未指定 |
| previousChange |
認可在目前版本之前已變更的專案 |
GitVersionType
版本類型(分支、標記或認可)。 決定如何解譯標識碼
| 值 | Description |
|---|---|
| branch |
將版本解譯為分支名稱 |
| commit |
將版本解譯為認可識別碼 (SHA1) |
| tag |
將版本解譯為標籤名稱 |
IdentityRef
| 名稱 | 類型 | Description |
|---|---|---|
| _links |
此欄位包含圖表主旨的相關零或更多有趣連結。 您可以叫用這些連結,以取得此圖表主題的其他關聯性或更詳細的資訊。 |
|
| descriptor |
string |
描述元是在系統執行時參考圖表主旨的主要方式。 此欄位會唯一識別帳戶和組織之間的相同圖表主題。 |
| directoryAlias |
string |
已淘汰 - 查詢 IdentityRef “_links” 字典中參考的 Graph 使用者,即可擷取 |
| displayName |
string |
這是圖形主體的非唯一顯示名稱。 若要變更此欄位,您必須在來源提供者中變更其值。 |
| id |
string |
|
| imageUrl |
string |
已淘汰 - 可在 IdentityRef “_links” 字典的 “avatar” 專案中取得 |
| inactive |
boolean |
已淘汰 - 可藉由查詢 GraphUser “_links” 字典的 “membershipState” 專案中參考的 Graph 成員資格狀態來擷取 |
| isAadIdentity |
boolean |
已淘汰 - 可以從描述元的主體類型推斷 (Descriptor.IsAadUserType/Descriptor.IsAadGroupType) |
| isContainer |
boolean |
已淘汰 - 可以從描述元的主體類型推斷 (Descriptor.IsGroupType) |
| isDeletedInOrigin |
boolean |
|
| profileUrl |
string |
已淘汰 - 未在 ToIdentityRef 的大部分預先存在實作中使用 |
| uniqueName |
string |
已淘汰 - 請改用 Domain+PrincipalName |
| url |
string |
此 URL 是此圖表主體來源資源的完整路由。 |
ItemContent
| 名稱 | 類型 | Description |
|---|---|---|
| content |
string |
|
| contentType |
ItemContentType
| 值 | Description |
|---|---|
| base64Encoded | |
| rawText |
ReferenceLinks
表示 REST 參考連結集合的類別。
| 名稱 | 類型 | Description |
|---|---|---|
| links |
object |
連結的只讀檢視。 因為參考連結是只讀的,所以我們只想要將其公開為只讀。 |
ResourceRef
| 名稱 | 類型 | Description |
|---|---|---|
| id |
string |
|
| url |
string |
VersionControlChangeType
對專案所做的變更類型。
| 值 | Description |
|---|---|
| add | |
| all | |
| branch | |
| delete | |
| edit | |
| encoding | |
| lock | |
| merge | |
| none | |
| property | |
| rename | |
| rollback | |
| sourceRename | |
| targetRename | |
| undelete |
VersionControlRecursionType
指定是否要包含子系 (OneLevel)、所有子系 (Full) 或 None
| 值 | Description |
|---|---|
| full |
傳回指定的專案和所有子系 |
| none |
只傳回指定的專案。 |
| oneLevel |
傳回指定的專案及其直接子系。 |
| oneLevelPlusNestedEmptyFolders |
傳回指定的專案及其直接子系,以及只包含單一資料夾的巢狀子資料夾遞歸鏈結。 |