Sharing code between two or more rails apps... alternatives to git submodules?
Posted
by jtgameover
on Stack Overflow
See other posts from Stack Overflow
or by jtgameover
Published on 2010-04-19T17:26:55Z
Indexed on
2010/04/19
21:13 UTC
Read the original article
Hit count: 180
We have two separate rails_app, foo/
and bar/
(separate for good reason). They both depend on some models, etc. in a common/
folder, currently parallel to foo
and bar
.
Our current svn setup uses svn:externals
to share common/
. This weekend we wanted to try out git. After much research, it appears that the "kosher" way to solve this is using git submodule
. We got that working after separating foo
,bar
,common
into separate repositories, but then realized all the strings attached:
- Always commit the submodule before committing the parent.
- Always push the submodule before pushing the parent.
- Make sure that the submodule's HEAD points to a branch before committing to it. (If you're a bash user, I recommend using git-completion to put the current branch name in your prompt.)
- Always run 'git submodule update' after switching branches or pulling changes.
All these gotchas complicate things further than add
,commit
,push
. We're looking for simpler ways to share common
in git. This guy seems to have success using the git subtree
extension, but that deviates from standard gitand still doesn't look that simple.
Is this the best we can do given our project structure? I don't know enough about rails plugins/engines, but that seems like a possible RoR-ish way to share libraries.
Thanks in advance.
© Stack Overflow or respective owner