Can not update submodule using GitHttpClient
I try to create a new branch with submodule change Microsoft.TeamFoundation.SourceControl.WebApi.GitHttpClient but get an error: Expected a Blob, but objected [previous-submodule-value] resolved to a Commit (path ‘/external/[submodule-name]’). So, as we can see it wants to get a commit, but as I see there is no way to pass it there like this.
Here is how I do it:
gitClient.CreatePushAsync(new GitPush
{
RefUpdates = new List<GitRefUpdate>
{
new GitRefUpdate { Name = "refs/heads/[new-branch-name]", OldObjectId = baseBranch.ObjectId }
},
Commits = new List<GitCommitRef>
{
new GitCommitRef
{
Comment = "Bump submodule",
Changes = new List<GitChange>
{
new GitChange
{
ChangeType = VersionControlChangeType.Edit,
Item = new GitItem { Path = "/external/[submodule-name]" },
NewContent = new ItemContent { Content = newHash, ContentType = ItemContentType.RawText }
}
}
}
}
}, [repo-id]);
I've tried some luck on developer-community, and you may find different useful discussions and links there (if needed), and I was redirected to ask it here. Here is a link to that discussion: https://developercommunity.visualstudio.com/t/Can-not-update-submodule-using-GitHttpCl/1537646?viewtype=all