我正在尝试写一个小助手扩展,以简化特征分支的创建。我已经有了最近活跃的工作项目和一个按钮,可以从特定项目中创建功能分支。
该名称已经正确格式化了,但是当功能已内置在VSCODE中时,我不想对分支创建逻辑负责。
我的第一个尝试是简单地调用 executecommand
并传递命令并请求的分支名称:
vscode.commands.executeCommand("git.branch", branchName);
可悲的是 branchName
参数被简单地被忽略,并且文本输入出现一样通过命令调色板执行命令时。简单的解决方案是简单地偷窃借用分支创建逻辑或进行CLI调用,但我很固执,并希望在可能的情况下避免这样做。
我几乎可以在任何地方找到有关此主题的任何信息。
https://code.visalstudio.com/api/api/api/references/references/commands/commands git命令
涵盖了通过URIS传递给命令的参数,但这对我也不起作用,
我将不胜感激。
I am trying to write a little helper extension to ease the creation of feature branches. I already have a view of recently active work items and a button to create a feature branch from a specific item.
The name is already being formatted correctly, but I do not want to be responsible for the branch creation logic when the functionality is already built into vscode.
My first attempt was to simply call executeCommand
and pass in the command and requested branch name like this:
vscode.commands.executeCommand("git.branch", branchName);
Sadly the branchName
parameter is simply being ignored and a text input appears just as it would when executing the command via the command palette. The easy solution would be to simply steal borrow the branch creation logic or make a cli call, but I am stubborn and would like to avoid doing that if possible.
I can barely find any information regarding this topic anywhere.
https://code.visualstudio.com/api/references/commands does not cover git commands
https://code.visualstudio.com/api/extension-guides/command#command-uris covers passing parameters to commands via uris, but this too does not work for me
I would appreciate any leads.
发布评论
评论(2)
您可以通过使用GIT扩展曝光的API避免打开输入箱,请参见 git扩展API 。
以上是来自
@builtin
git扩展描述的扩展描述。因此您可以使用:
You can avoid the InputBox opening by using the API that the git extension exposes, see git extension api.
The above is from the extension description for the
@builtin
git extension description.So you could use:
似乎
git.branch
命令不支持参数,您可以在此处看到https://github.com/microsoft/vscode/blob/10e6e876822fa2da15fb68e8a6f1fb9aa8d94ce2/extensions/git/src/commands.ts#L1884-L1887
In在这种情况下,我建议您在VS代码回购中打开一个问题,并要求向VS代码团队扩展命令,以支持这种情况。
他们最近添加了随机分支名称功能,所以我想这样的请求将受到好评。
希望这会有所帮助
It seems the
git.branch
command does not support parameters, as you can see herehttps://github.com/microsoft/vscode/blob/10e6e876822fa2da15fb68e8a6f1fb9aa8d94ce2/extensions/git/src/commands.ts#L1884-L1887
In this case, I suggest you should to open an issue in VS Code repo and ask to the VS Code team to expand the command, to support such scenario.
They recently added a random branch name feature, so I suppose such request would be well received.
Hope this helps