使用 git 进行多扩展开发时的正确策略
我已经解决了git相关的问题,但一直无法下定决心。
我开发了许多扩展,我想从 svn 迁移到 git,以便能够使用更好的分支和组织。
我为 Magento 开发扩展,其中扩展的各个部分不位于 1 个文件夹下,而是分布在整个文件夹结构中。
我的扩展在以下文件夹中包含文件:
- /app/code/community/mynamespace
- /app/design/frontend/base/default/layout/mynamespace
- /app/design/frontend/base/default/template/mynamespace
- /app/etc/ module /skin/frontend/base/default/css/mynamespace
- /skin/frontend/base/default/js/mynamespace
这些文件夹也都包含来自其他扩展的文件。
我希望能够独立开发和测试扩展。我知道我可以将其与分支/更改或功能一起使用,这非常棒。
虽然我希望能够检查它们/扩展名,这意味着只有那些属于某个扩展名的文件才会被拉出。
我可以执行以下操作吗?
- 将每个扩展放入其自己的存储库?
- 将每个扩展嵌入到包含主要 magento 代码的超级存储库中,以便可以使用子树或子模块来测试扩展?
这种方法到底有效吗? 还有其他我不知道的方法吗?
预先非常感谢。
编辑:
我应该创建一个空存储库,然后将空存储库分支到与扩展一样多的分支。 那么我应该能够将代码合并回 master,并在各个分支上进行开发。在这种情况下,当向主控添加内容后我需要一个新的空分支来进行新扩展时会发生什么?我可以创建一个空分支并分支吗?这可能吗?
谢谢大家,我想我已经接近一个好的解决方案了。
I have got through the git related quesions and I have not been able to make up my mind.
I have many extensions that I have developed and I want to move from svn to git to be able to use better branching and organization.
I develop extensions for Magento where you the parts of the extensions are not located under 1 folder but are spread across the folder structure.
My extensions have files in the following folders:
- /app/code/community/mynamespace
- /app/design/frontend/base/default/layout/mynamespace
- /app/design/frontend/base/default/template/mynamespace
- /app/etc/modules /skin/frontend/base/default/css/mynamespace
- /skin/frontend/base/default/js/mynamespace
these folders all contain files from other extensions as well.
I want to be able to develop and test the extensions independently. I know I can use this with branch / change or feature which is great.
Although I would like to be able to check them out / extensions which means only those files are pulled which belong to a certain extension.
Can I do the following ?
- put each extension to it's own repository ?
- embed each extension into a super repository which contains the main magento code so that the extensions can be tested either using sub-tree or submodules ?
Would this approach work at all ?
Is there any other way that I am not aware of ?
Thanks a lot in advance.
EDITED:
Should I create an EMPTY REPO, then branch the empty repo to as many branches as extension.
then I should be able to merge back the code to master, and do development on the individual branches. In this case what happens when after adding things to the master I need a new empty branch for a new extension ? Can I create an empty branch and branch that ? Is that even possible ?
thanks guys, I thing I am getting closer to a good solution.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果每个扩展彼此独立,您可能可以将每个扩展维护在单独的分支中(而不是像您建议的那样拥有自己的存储库)。
例如,如果您开发了 3 个扩展,那么您的 git 树中将有四个开发分支:
每次 magento 代码更改时,您都将其拉入 master,然后在 master 中的最新更改之上重新调整您的三个开发分支。
如果你想对它们全部进行测试,只需创建一个新的测试分支并将 master、extn1、extn2 和 extn3 合并到其中即可。
If each extension is independent of the other, you could probably maintain each in a separate branch (instead of it's own repository as you suggest).
e.g. If you developed 3 extensions, you would have four development branches in your git tree:
Everytime the magento code changes, you pull it into master and then rebase your three development branches on top of the latest changes in master.
And if you want to test with them all, just create a new test branch and merge master, extn1, extn2 and extn3 into it.
如果您的模块彼此完全无关,我会在它们自己的存储库中创建它们。出于测试目的,请在其自己的独立文件夹中创建您想要开发的 Magento 版本的空白安装。然后在其中的适当位置创建指向您提到的 5 个文件夹的符号链接。
为了测试开发,创建一个仅包含该存储库内容的项目,但由于没有主要源代码的开发会令人困惑,因此大多数 IDE 允许您包含其他文件夹中的代码,因此添加您要为其开发测试的 Magento 版本,以便您可以轻松引用代码库。
现在您应该能够在工作时进行测试,分发模块可以是 git 导出和压缩内容的简单情况。然后,您将拥有一个简单的 zip 文件,就像任何其他分布式 Magento 模块一样,没有 Magento 核心文件。
实际上,我刚刚开始开发基于 phing 的构建工具,以使 Magento 扩展开发更容易(您可以在 https 找到它) ://github.com/pocallaghan/mephing),但它还处于早期阶段,目前缺乏任何文档。
If your modules are completely unrelated to each other I would create them in their own repositories. For testing purposes, create in it's own independent folder a blank install of whichever version of Magento you wish to develop for. Then create symlinks to the 5 folders you mention in the appropriate places within this.
For testing development create a project which includes just the contents of that repository, but since development without the main source is confusing, most IDE's allow you to include code from an additional folder, so add in whichever version of Magento you are developing testing for, so that you can easily reference the code base.
Now you should be able to test as you work, distributing the module can be a simple case of git exporting and zipping the contents. You then have a simple zip file like any other distributed Magento module, sans Magento core files.
I've actually just started working on a phing based build tool to make Magento Extension development easier, (which you can find at https://github.com/pocallaghan/mephing), but it's in it's early stages and currently lacks any documentation.
答案非常简单,我想 NomadCoder 提供了解决该问题的好方法。我的建议是创建开发分支和发布分支,这将有助于指导工作流程。由于合并分支很容易,这将有助于您的工作流程透明。这里有一个 git 代码列表,您可能会发现适合您的情况
Git Brushup
The answer is pretty straight forward and I guess NomadCoder presented great way to solve the problem . My suggestion would be to make Development Branch and Release Branch which will help to direct workflow. And since merging branches is easy it will help your work flow transparent. Here a list of git codes you might find handy in your case
Git Brushup
是的,这是可以完成的,并且是我为扩展开发所做的事情。我实现这一目标的方法是使用以下步骤:
此后,我的 Magento 安装根目录中有以下 git 文件:
现在,我可以同时处理所有项目。例如,如果我想从 WP 项目推送更改,我可以运行以下命令:
使用上述系统,我可以轻松地在同一个 Magento 环境中处理我的所有扩展,同时保留单独的存储库。
我希望这有帮助
Yes, this can be done and is something I do for my extension development. The way I achieved this is using the following steps:
After this, I have the following git files in the root of my Magento install:
Now, I can work all my projects at the same time. If for example, I want to push my changes from the WP project, I can run the following commands:
Using the above system I can easily work on all of my extensions in the same Magento environment, while keeping separate Repository's.
I hope this helps