Archive

Archive for March, 2011

Cross-SCM (git and subversion) projects with modman

March 3rd, 2011

I recently had a need to include some code from two subversion repositories in a git-based project. A bit of Googling brought me to the disappointing conclusion that there is no easy maintenance-free way of doing this with git.. Modman to the rescue! With a simple one-liner added to my modman file I can accomplish what is essentially an svn:externals declaration in my git-based project, or a subversion repository as a git submodule! Behold:

EDIT: Updated to use multi-line continuations for readability.

# Substitute for svn:externals
@shell \
  SRC=https://example.com/source/magento/common; \
  DEST=modules; \
  if [ -d $DEST/.svn ]; then \
    svn update $DEST; \
  else \
    svn checkout $SRC $DEST; \
  fi

# Import subversion-based modules
@import    modules/Foo
@import    modules/Bar

Now, when I clone the module (git is supported natively as of 1.1.0) or any time I run an update, deploy or repair, the subversion modules will be checked out or updated as well. So, if you ever need to mix and match SCM’s, go right ahead. I still recommend the use of git submodules for all-git projects and svn:externals for all-subversion projects, of course.

I’ll consider adding a builtin function that tidies up the above and handles things like switching urls..

Uncategorized