将 Git 与 VB6 结合使用
我们公司拥有大量 VB6 代码库,目前我们使用 VSS,尽管我们讨厌它,但它至少集成到了 VB6 IDE 中。
我自己的团队正在使用 .NET,现在正在研究替代 SCM,例如我个人最喜欢的 Git。有了 Git 扩展,我们似乎能够很好地将 Git 命令集成到 Visual Studio IDE 中。
然而,有人提出了一个问题:Git 也可以用于我们的 VB6 代码库吗?
当然,我假设文件本身在 git 存储库中可以正常工作,但毫无疑问,如果开发人员必须使用命令行来完成所有源代码控制,他们会抱怨。但是有人有使用 VB6 和 Git 的经验吗? VB6 IDE 中是否有可用的集成?或者说,如果没有 IDE 集成,也许并没有那么麻烦?
我会因为第一个创建 [vb6] 和 [git] 的荒谬标签组合而获得徽章吗?
Our company has a large codebase in VB6, and we currently use VSS which, for all that we hate about it, at least integrates into the VB6 IDE.
My own team, which is using .NET, are now looking into alternative SCMs like my personal favourite, Git. With Git Extensions, it seems we will be able to integrate Git commands into the Visual Studio IDE pretty well.
However, the question has been asked: could Git be used for our VB6 codebase too?
Of course I assume the files themselves would work fine in git repositories, but no doubt developers would complain if they had to use the command-line to do all their source control. But has anyone had any experience using VB6 and Git? Any integration available from within the VB6 IDE? Or is it perhaps not that much of a hassle to not have the IDE integration?
And do I get a badge for being the first to create the absurd tag combination of [vb6] and [git]?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
我发现这个解决方案适合我们的情况。它为之前的答案添加了更多内容,并解决了让我们的项目与 git 一起工作的所有许多问题。
.gitattributes
.gitignore
I found this solution to work in our situation. It adds a bit more to the previous answers and solved all of our MANY issues getting our project to work with git.
.gitattributes
.gitignore
使用 Git 管理 VB6 项目已经大约一年了。从未遇到过任何 IDE 集成。就我个人而言,我喜欢命令行,所以我没怎么看。我遇到的两个主要问题是:
Been using Git to manage VB6 projects for about a year now. Never came across any IDE integration. Personally I like the command line, so I've not been looking much. The two major issues I've encountered are:
您必须创建文件.gitattributes才能使用Windows行结尾(crlf),因为git诞生于unix。
还使用以下行创建 .gitignore 文件:
You have to create the file .gitattributes to use windows line endings (crlf) because git was born in unix.
Also create .gitignore file with the following lines:
这确实是对 KeithTheBiped 等人的其他精彩评论的补充...
但是,可以在某种程度上强制 VB6 中的立即窗口表现得像现代终端窗口,但有一些注意事项。如果我们创建一个辅助函数来运行命令,以某种方式捕获输出,然后使用 Debug.Print 将其转发回类似于终端窗口的立即窗口,但当然没有任何交互元素。
这适用于大多数命令,但无法捕获 git push 阶段的一些输出。一个可以接受的妥协,为了方便无外壳(imo)。
我们可以使用命令提示符 (
cmd.exe /c
) 使用针对临时文件的1>
和2>
管道来完成此操作。我不提供几个底层函数,但如果您还没有它们,请提供源代码。考虑以下函数:
您将需要:
一旦你完成了这个,并且可以成功地运行任何简单的执行并输出到立即窗口中,如下所示:
从这里,你可以运行 Git,并将大部分内容显示到立即窗口中,并且可以像这样简单地使用它,但是我们可以做得更好。
假设您已经安装了命令行 Git 并且更新了路径以使其可用,您可以创建一些新函数(希望在模块中):
从这里,您几乎可以从立即窗口运行 Git 命令。请记住,Git() 是一个函数,因此您必须将参数作为字符串传递...只是一个必要的字符。当然,VB 会自动完成一个字符串,所以你不需要尾随,但我会包含它。使用语法:
它不允许交互式 git 命令 (
git add -p
),但是,您可以暴力破解它 (git add . -f
)。但是,命令运行并直接将其输出显示到“立即”窗口中,无需太多其他工作。你明白了。
从那里,您还可以实现自动化。创建辅助函数来批处理常用的 Git 命令等,或者只是消除一些笨重的语法。使用 RunCmdToOutput,如果愿意的话,您还可以重新处理其中的一些内容以使用 MsgBox,但我认为立即窗口足够直观。
在某些时候,将任何函数限制为仅在 IDE 中运行可能也很重要,但这是可选的。
This really is an addition to the other excellent comments by KeithTheBiped, et al...
But, it is possible to somewhat coerce the Immediate Window in VB6 to act like a modern terminal window, with some caveats. If we create a helper function to run the command, capture the output somehow, and then use Debug.Print to relay that back to the Immediate window SIMILAR to the terminal window, but without any interactive elements, of course.
This works for most commands, but fails to capture some of the output in the
git push
phase. An acceptable compromise, for the convenience of no shell (imo).We can do just that using the the command prompt (
cmd.exe /c
) using the1>
and2>
pipes aimed at temporary files. I don't supply a couple underlying functions, but provide sources if you don't have them already.Consider the following function:
You will need:
Once you have accomplished this and can successfully run any simple executing and output into the Immediate window like this:
From here, you can run Git, and display MOST things into the Immediate window, and could use it as simple as that, but we can do better.
Assuming you have already installed a command-line Git and the path is updated so that it is available, you can create a few new functions (hopefully in a module):
From here, you can ALMOST run Git commands from the immediate window. Remember, Git() is a function, so you have to pass in the argument as a string... Just one necessary character. Of course, VB will auto-complete a string, so you don't NEED the trailing quite, but I'll include it. Use the syntax:
It doesn't allow interactive git commands (
git add -p
), but, you could just brute-force it (git add . -f
). But, the commands run and directly display their output into the Immediate window without much other effort.You get the idea.
From there, you can also automate things. Create helper functions to batch commonly used Git commands, etc, or just eliminate some of the clunky syntax. With
RunCmdToOutput
, you can also re-work some of it to use the MsgBox, if preferred, but I thought the Immediate Window was intuitive enough.It might also be important at some point to restrict any functions to only run in the IDE, but that's optional.
您最了解您的开发人员。他们介意使用命令行吗?他们热衷于 IDE 集成吗?这些都是个人喜好。
确保最受尊敬的开发人员了解 git 的好处并支持决策。
请注意,某些 VB6 源文件是二进制的,永远不要合并:例如
.frx
文件。我不懂git,所以我不知道这是否有问题。You know your developers best. Will they mind using the command line? Are they keen on IDE integration? These are personal preferences.
Make sure the most respected developers understand the benefits of git and are behind the decision.
Do be aware that some VB6 source files are binary and shouldn't ever be merged: e.g.
.frx
files. I don't know git, so I don't know whether that's a problem.VB6 作为代码库(即文本文件)有何不同,导致它不适合 git?
文化则完全是另一回事:如果您有很多无能的开发人员无法处理命令行,那么解决方法可能包括尽可能远离 VB6。
唯一的潜在问题是 Windows 在 git 世界中有点像二等公民。如果您发现 git 在您的环境中运行得不太好,您可能想尝试 bazaar 或 Mercurial。
What's so different about VB6 as a code base (i.e. text files) that makes it not suitable for git?
The culture is another matter altogether: if you have plenty of incompetent developers who can't handle the command line, the cure would probably include running away from VB6 as far as you can.
The only potential problem is that windows in the git world is somewhat of a second class citizen. You might wanna try bazaar or mercurial if you find git doesn't work very well in your environment.
我们正在这样做。我们已将以下内容添加到 .gitIgnore
We are doing this. We have added the following to .gitIgnore
我正在使用 Atlassian Source 树来管理 git 存储库中的 VB6 项目。工作正常。
如前所述,一个障碍是,当在 IDE 中定义标识符时,IDE 会关闭并更改匹配标识符的大小写,而这些会产生一系列虚假的更改。
解决方案是在文本文件中保留一块标识符,并根据需要将它们放入每个文件的(常规)(声明)部分,如下所示:
这将强制索引的所有实例为索引等。如果你得到一个当代码更改时会出现一堆 IDE 编辑,您只需粘贴到标准外壳中,然后再次保存文件即可。
I am using Atlassian Source tree to manage my VB6 projects in git repositories. Works fine.
As mentioned, one hurdle is that when an identifier is defined in the IDE, the IDE goes off and changes the case of matching identifiers and these produce screeds of changes that are all spurious.
The solution is to keep a block of identifiers in a text file and slap them into the (General) (Declarations) part of each file as needed like this:
This will force all instances of index to be Index, etc. If you get a bunch of IDE edits appearing as code changes, you simply paste in the standard casing, and save the file again.
有一个针对旧的 VB6-IDE、VC6-IDE 的解决方案,它使用 MSSCCI,并且可以集成到每个提供 MSSCC 接口进行源代码控制的 IDE 中。
你可以在这里找到它 Visual Git。
there is a solution for the old VB6-IDE, VC6-IDE that uses the MSSCCI and can integrate in every IDE providing MSSCC interface for source control.
you find it here Visual Git.