Search code examples
automationcommand-line-interfaceproject

A tool to manage source libraries in a project (without submodules)?


Is there a command-line tool to automate maintaining a collection of source libraries and applying them to projects?

For gamejams (or possibly also longer-term projects), I don't want to host my own clone of each library I use to be able to modify it (and grant each member of my team permission on each clone). Instead, I want all of my source code inside my project source tree -- which means I can't use git submodules.

So say I have a project "puppypark" and I want to use some libraries "baton" and "windfield".

I'm looking for this kind of workflow:

  • register libraries
    • librarian add baton git://lib.com/baton.git
    • clones to a central repository (e.g., in ~/.librarian/)
  • add libraries to a project
    • librarian use baton puppypark ./src/foreign/
    • creates a branch (off master) for that project in the central repository
  • merge project changes into central repository
    • librarian apply puppypark
    • switches to project's branch and copies changes into clone
  • merge upstream changes into project
    • librarian apply baton puppypark
    • takes the current state of project's branch and copies to project
  • no actions occur unless the target repository has a clean workspace
  • actions always result in commit summarizing the action taken
    • commits should always have a commit id (sha)

This could be independent of my version control system, but if it did it with git, that's great too.

I think this is kinda like Carthage (but for source instead of built libraries and I'm not interested in dependencies). Maybe I can achieve some of this with git-subtree, but I don't understand how. I think this is like loverboy, but I'm interested in a more general solution.


Solution

  • I couldn't find a solution, so I wrote my own: librarian automates copying modules to and from projects. Unlike loverboy, you give it general rules for how to copy modules instead of requiring rules for each module.

    Example usage to setup for love2d and import windfield into project "puppypark":

    librarian config love --path src/lib/ --root-marker init.lua --rename-single-file-root-marker ".*.lua" --include-pattern ".*.lua|LICENSE.*"
    librarian acquire love windfield https://github.com/adnzzzzZ/windfield.git
    librarian checkout puppypark windfield
    librarian checkin puppypark windfield