英文:
How can I pass multiple commits to a Cherry Pick API in Azure DevOps?
问题
我有一个需求,我需要从Cherry Pick API为我创建的临时分支中选择特定的提交列表,而不是选择一个提交,然后提出一个拉取请求。我没有找到任何示例脚本来实现这个目标。有人可以帮帮我吗?我在各处都找到以下代码。
$requestbody= @{
"generatedRefName" = "refs/heads/sourcebranch";
"ontoRefName" = "refs/heads/targetbranch";
"repository" = @{
"name"= $RepoName
};
"source" = @{
"commitList"= @(
@{
"commitId" = "405d4e27a4ac33fcfc489076ae3b890571619483"
}
)
}
}
我需要的是以下内容。
$requestbody= @{
"generatedRefName" = "refs/heads/sourcebranch";
"ontoRefName" = "refs/heads/targetbranch";
"repository" = @{
"name"= $RepoName
};
"source" = @{
"commitList"= @(
在此列表中传递多个提交
)
}
}
如果您需要将多个提交添加到 "commitList" 中,您可以使用类似以下的格式:
"commitList"= @(
@{
"commitId" = "第一个提交的ID"
},
@{
"commitId" = "第二个提交的ID"
},
{
... (继续添加更多提交)
}
)
英文:
I do have a requirement where I need to create cherry pick only the specific list of commits instead of one commit and then raise a pull request from the temporary branch which Cherry Pick API creates for me. I didn't find any sample script to achieve. Can someone please help me ? I find the below code everywhere.
$requestbody= @{
"generatedRefName" = "refs/heads/sourcebranch";
"ontoRefName" = "refs/heads/targetbranch";
"repository" = @{
"name"= $RepoName
};
"source" = @{
"commitList"= @(
@{
"commitId" = "405d4e27a4ac33fcfc489076ae3b890571619483"
}
)
}
}
What I need is as below.
$requestbody= @{
"generatedRefName" = "refs/heads/sourcebranch";
"ontoRefName" = "refs/heads/targetbranch";
"repository" = @{
"name"= $RepoName
};
"source" = @{
"commitList"= @(
pass multiple commits in this list
)
}
}
答案1
得分: 2
代码部分不需要翻译。以下是翻译好的内容:
"commit list is just an array of GitCommitRef
." 翻译为:提交列表只是一个 GitCommitRef
数组。
"That means you can use multiple commits like this:" 翻译为:这意味着您可以像这样使用多个提交:
"source = @{" 翻译为:source = @{
"commitList = @" 翻译为:commitList = @(
"commitId = '4a419de68788eeb8888c0d04513d48e01ed88a17';" 翻译为:commitId = '4a419de68788eeb8888c0d04513d48e01ed88a17';
"commitId = '7feb89d53c155940b9c19ea2d683575865cba911';" 翻译为:commitId = '7feb89d53c155940b9c19ea2d683575865cba911';
英文:
It is actually pretty simple: commit list is just an array of GitCommitRef
. That means you can use multiple commits like this:
source = @{
commitList = @(
@{
commitId = '4a419de68788eeb8888c0d04513d48e01ed88a17'
},
@{
commitId = '7feb89d53c155940b9c19ea2d683575865cba911'
}
)
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论