1

I have a serious problem (!!!) about organizing my develop environment;

I have two apps: app1 and app2. This apps are written using OpenUI5 (but this detail is not important)

app1 and app2 are similar and share some code (for example the code to login). I use git (with git-flow) with two remote repo and I have all equal code duplicate. Now I want optimize my develop-flow sharing equal code (login code).

This is my first idea: have only one repo contains all my code in a structure of this type:

repo
|_____share
|     |____login.js
|
|_____app1
|     |_____index.html
|     |_____resources
|           |_________util1.js
|_____app2
      |_____index.html
      |_____resources
            |_________util2.js

I have two time state:

  • DEVELOP time where each index.html uses resources/utilX.js and ../share/login.js
  • RELEASE time where each index.html uses resources/utilX.js and resources/login.js

Good! I can create (using grunt?) a RELEASE for each app; for example the result of RELEASE is

app1
|_____index.html
|_____resources
      |_________util1.js
      |_________login.js.js

I can push app1 folder to my server and it works fine!

But now I have some doubt:

  1. Using git-flow I have master and develop branch; with only one repo I have only one mastes and consequently when on app1 I want to do a release I must tag the full master with a new release. I don't like it, I would like two apps with their own number version
  2. Is better have two separate repo (repo_app1 & repo_app2)? And in this case where are the share files?
  3. In other (compiled)language I can create release version whit only compiled files of an app. Grunt is the right way to prepare the app folder to push on my server?
padibro
  • 1,324
  • 10
  • 56
  • 95

2 Answers2

2

Git Submodules might be helpful for you. It will allow you to move app1, app2 and shared code to different repos and then inject shared code repo to your app repos. For more information read documentation

Alexey Andrushkevich
  • 5,992
  • 2
  • 34
  • 49
  • Thanks Alexey. I have a question: If I use submodules how can I modify shared-code? I can't modify the share-code without test it, and I can test it only if I use it in app1 or app2. I would like include for example share-code repo in app1 repo, open app1 repo and modify&commit share-code. Can I do it? – padibro May 22 '15 at 14:27
  • That's what git submodules are for. You inject your shared library repository to the application repository and it would look just like an usual folder except the thing this folder points to another repository. – Alexey Andrushkevich May 22 '15 at 14:46
  • If you are about technical side of course it will be a bit harder than just using one repository. See this [question](http://stackoverflow.com/questions/3590400/git-commit-to-common-submodule-master-branch) for example. – Alexey Andrushkevich May 22 '15 at 14:53
1

An other solution could be to use subtrees.
It allow to share code between projects, typically in case of dependencies, and it allows to communicate in both directions:

  • You can modify your shared code and decide to integrate it in app1 or app2 at different times, each of them are completely independent.
  • In the same way you can perform modifications of shared code in app1, push it to shared code repository and decide later to integrate it in app2

The official documentation is here :
http://www.git-scm.com/book/en/v1/Git-Tools-Subtree-Merging

A great tutorial performing submodules vs subtree comparison with detailed explanations could be found here :
http://typecastexception.com/post/2013/03/16/Managing-Nested-Libraries-Using-the-GIT-Subtree-Merge-Workflow.aspx

Juergen
  • 12,378
  • 7
  • 39
  • 55
Quicky
  • 403
  • 1
  • 4
  • 10