Proper Git workflow for combined OS and Private code?

后端 未结 6 1742
情歌与酒
情歌与酒 2020-12-17 18:14

I have a closed source project that is built on my open source framework. I want to know how I should structure my workflow. Below is my best guess using git with submodules

6条回答
  •  醉酒成梦
    2020-12-17 18:41

    To summarize, I recommend this workflow:

    1. keep it simple; have one working copy for each repository (don't use git submodules)
    2. use your language's tools to package up your framework
    3. setup scripts or light tooling to make context switching fast or automatic

    I've used git submodules in the past. I don't think they are a good fit for your use case. The big downsides that jump out at me are:

    • It helps to eat your own dog food when you build (or extract) a framework. Do you expect your framework users to also setup git submodules when they use your framework? I'm guessing not.
    • There is some risk of accidentally publishing your private source code into your open source framework.
    • Git submodules have improved quite a bit in the last year or so, but they still are relatively less well understood. Even competent gitters may struggle with submodules.

    Here is one sub-question that I will admit is not so clear cut: "Which workflow makes it easier to bounce back and forth between the OSS framework and the private project?"

    • There is a certain allure to using submodules and having both projects in one tree. This will speed you up perhaps in your text editing, but probably will slow you down (or cause more mistakes than usual) when it comes to committing and pushing.

    • There is a certain allure to having the projects separated. The context switch (from one text editor window to another) may help remind you that the OSS project is for public consumption. For example, it may help discipline you to not to break backwards compatibility and to keep a good changelog. Committing and pushing will be easy relative to the submodule alternative.

    One you have decided on your working copies, you'll want to figure out your day to day workflow. It will depend on your language of course. (In Ruby, for example, you might package up your OSS framework as a gem, build it, then have your private code depend on it.) Whatever you pick, setup some scripts (or editor shortcuts perhaps) to help you build your libraries (or packages) quickly, perhaps even automatically when files change, so that you can bounce between your framework and project effortlessly.

提交回复
热议问题