我在 Azure Git 存盤庫中有一個 java maven 專案(Eclipse)。這是一個基于excel中給出的輸入在系統中創建資料的測驗專案。目前,在運行測驗之前,我使用 git 在本地機器上克隆了整個專案,更新輸入的 excel 檔案并推送到 Azure 存盤庫。有沒有辦法直接將更改推送到存盤庫中的輸入 excel 檔案,而無需將整個專案檔案夾下載到本地?
uj5u.com熱心網友回復:
也許,使用
...自然地,它會創建一個提交,但這很容易。我之前在沒有 IDE 的情況下通過簡單地在線編輯 repo 中的現有檔案進行了代碼更改。
uj5u.com熱心網友回復:
您可以使用 REST 和 Powershell 來更新遠程倉庫上的檔案......例如:
$user = ""
$token = "<PAT>" #https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops&tabs=preview-page
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user,$token)))
$orgUrl = "https://dev.azure.com/<org>"
$teamProject = "TestProject"
$repoName = "Repo1"
$localFilePath = 'c:/temp/tst.xlsx'
$gitFilePath = 'testfolder/tst.xlsx'
$gitBranch = "master"
$restApiUpdateFile = "$orgUrl/$teamProject/_apis/git/repositories/$repoName/pushes?api-version=6.1-preview.2"
$restApiGetMasterRef = "$orgUrl/$teamProject/_apis/git/repositories/$repoName/refs?filter=heads/$gitBranch`&api-version=6.1-preview.1"
$fileContentToUpdate = [convert]::ToBase64String((Get-Content -path $localFilePath -Encoding byte))
function InvokeGetRequest ($GetUrl)
{
return Invoke-RestMethod -Uri $GetUrl -Method Get -ContentType "application/json" -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}
}
function InvokePostRequest ($PostUrl, $body)
{
return Invoke-RestMethod -Uri $PostUrl -Method Post -ContentType "application/json" -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -Body $body
}
$updateBody = @"
{
"refUpdates": [
{
"name": "refs/heads/{gitbranchpath}",
"oldObjectId": "{mainBranchObjectId}"
}
],
"commits": [
{
"comment": "Updates file",
"changes": [
{
"changeType": "edit",
"item": {
"path": "{filePathToUpdate}"
},
"newContent": {
"content": "{newFileContentToUpdate}",
"contentType": "base64encoded"
}
}
]
}
]
}
"@
$res = InvokeGetRequest $restApiGetMasterRef
$updateBody = $updateBody.Replace("{gitbranchpath}", $gitBranch);
$updateBody = $updateBody.Replace("{mainBranchObjectId}", $res.value[0].objectId);
$updateBody = $updateBody.Replace("{filePathToUpdate}", $gitFilePath);
$updateBody = $updateBody.Replace("{newFileContentToUpdate}", $fileContentToUpdate);
InvokePostRequest $restApiUpdateFile $updateBody
uj5u.com熱心網友回復:
我們沒有辦法直接在 Web 瀏覽器上打開和編輯 Git 存盤庫中的 Excel 檔案。
我嘗試過幾個基于 Git 的版本控制平臺(Azure Git Repos、GutHub、GitLab、Bitbucket 等)。然后都不能允許用戶直接打開和編輯 Git 存盤庫中的 Excel 檔案。
我也沒有找到任何可用的擴展可以幫助做到這一點。
因此,您需要將 Excel 檔案下載到安裝 MS Office 的本地,然后在本地打開并編輯它。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/399694.html
標籤:擅长 混帐 azure-devops
上一篇:使用游標在Prisma中分頁很慢
