【发布时间】:2018-09-30 08:05:19
【问题描述】:
我正在尝试以编程方式更新现有分支中的文件,但出现此异常。
参数组合无效或不完整。 参数名称:refUpdate
这是我的代码:
GitRefUpdate desiredBranch = new GitRefUpdate()
{
RepositoryId = sourceRepoGuid,
OldObjectId = branch.ObjectId
};
GitCommitRef newCommit = new GitCommitRef()
{
Comment = $"Update config to match new branch ",
Changes = new GitChange[]
{
new GitChange()
{
ChangeType = VersionControlChangeType.Edit,
Item = new GitItem() { Path = $"/{fileName}" },
NewContent = new ItemContent()
{
Content = fileContent,
ContentType = ItemContentType.RawText,
},
}
},
};
GitPush push = gitClient.CreatePushAsync(new GitPush()
{
RefUpdates = new GitRefUpdate[] { desiredBranch },
Commits = new GitCommitRef[] { newCommit }
}, sourceRepoGuid).Result;
我会从错误消息中想象我对 GitRefUpdate 对象做错了什么。我已经尝试了OldObjectId、NewObjectId 与从文件的最后一次提交到分支本身的 SHA 的 SHA 的几种不同组合,没有任何东西可以满足对 CreatePushAsync 的调用。
我发现的唯一示例是在 MS 示例中,它创建了一个新分支并添加了一个新文件。我想更新现有分支中的现有文件。
我没有想法。
【问题讨论】: