Visual Studio 可扩展性:从团队资源管理器的 Git 提交详细信息页面获取 Git 存储库的路径

Visual Studio Extensibility: Get the Git repository's path from Team Explorer's Git Commit Details page

我正在将 Git 集成添加到我的 Visual Studio 扩展 Diff All Files, which allows for quickly diffing (i.e. comparing) all files in the Team Explorer window with a previous version. I have it working with the Git Changes page (in Team Explorer), since when I get the Microsoft.TeamFoundation.Git.Controls.Extensibility.IChangesExt service the files in it's IncludedChanges property contain the full file path on disk. However, when working with the Git Commit Details page I get the Microsoft.TeamFoundation.Git.Controls.Extensibility.ICommitDetailsExt service,其更改 属性 仅包含相对于 git 分支的文件路径。

我正在使用 the LibGit2Sharp library 与 Git 存储库交互,并且能够访问 git 存储库 LibGit2Sharp 需要文件路径在存储库中。由于 ICommitDetailsExt Changes 属性 仅包含相对于 git 存储库的文件路径,我不知道如何获取 Git 存储库的路径(因此我可以检索以前版本的要比较的文件)。

起初我以为我可以使用 DTE 对象访问解决方案文件的路径,但意识到可以从团队资源管理器查看待处理的更改和以前对 Git 存储库的提交,而无需打开解决方案本身,这样就不起作用了。

那么我如何知道 Git 提交详细信息页面显示的提交来自哪个 Git 存储库? None ICommitDetailsExt 服务上的其他属性似乎有我想要的存储库信息(即存储库中文件的完整文件路径)。是否有其他服务可以为 Git 提供商提供信息?

我也发了this question on the MSDN forums希望微软能给个答案

提前致谢。

虽然可能不理想 - 一种选择(对于 VS 2013 Update 3+ 和 VS 2015)是使用 IGitExt 扩展点来获取当前的活动存储库。这是在 Visual Studio 2013 Update 3 中添加的,因此这不适用于早期的客户端。 IGitExt 包含一个 属性 来获取当前的 ActiveRepositories(目前只包含一个项目)。

我(还)没有在 msdn 上找到这方面的文档,但您可以查看 GitHub 的 Visual Studio 扩展以了解他们如何使用它作为 getting the IGitExt service and accessing the ActiveRepositories 的示例属性.