3

My team and I have developed a Chrome extension which we are now porting into Firefox. The two versions share enough of a code base that it would be redundant to manage to separate depos. In fact theoretically the difference is within a few files and folder structure (once we unglue a lot of the platform specific code from the internals).

The Chrome extension houses all the files in the root directory, because all Chrome needs is the manifest file and the files can be located anywhere. This is different from the FireFox plugin, because FireFox requires a specific folder structure and where the files are located.

I haven't really found any discussions dealing specifically with managing multiple versions of the same project, yet maintaining a common shared code base. If you know of any articles/discussions, please let me know!

The structure for our Chrome extension is:

 Root
   [House Extension Scripts]

however the firefox requires the following structure:

 Root
    |-Data
        |-[Houses Page Injected Scripts]
    |-Lib
        |-[Houses Plugin Side Scripts]
    |-package.json

which makes merging and maintaining a common code base a little tricky. In those case Root in Chrome and Data in Firefox contain mostly common files (with a few exception). I am not sure how to do this in Git. In Perforce you can select which folders get merged into which folders. So I would merge the a common Dev folder into the root of the chrome extension folder and into the data folder of the FireFox plugin.

In my mind, the Git branching structure would be something like this:

      Firefox-Master/-----------------|-------------------------|---
                   /                 ↗                         ↗
      Firefox-Dev /-------------|---|--------|-------|---------|---
                 /             ↗            ↗        ↘
         Dev -----------------|-------------|----------|-----------
                 \             ↘          ↗            ↘
       Chrome-Dev \ ------------|---|----|---------------|----|----
                   \                 ↘                        ↘
     Chrome-Master  \-----------------|------------------------|----

where the Dev branch houses the common code base. Each plugin has it's own dev folder, because each version needs it's own seperate code files to work. If there is something that get's developed in the FireFox-Dev branch that can be incorportated into Chrome, it will first be merged into Dev and then Dev will be merged into the Chrome-Dev branch. Each Master is independent as it is treated as a "release" branch.

I am wondering how this is managed on projects that have products ported across multiple platforms. For instance the Linux kernel for x86 and ARM must have a similar issue.

The biggest hurdle here is the fact that both require a different folder structure. I am wondering how this issue is tackled using Git. I want to be able to develop in one branch and be able to merge any non-platform specific code into the other versions while maintaining their unique folder structures.

Please let me know if this is a vague question and if I need to update any of the graph to be more clear. Any help is greatly appreciated!

3

I am not familiar with plugin development at all.

However, where your code is in the source control and how you present it to either browser can be separated by adding a build step.

With that model:

  • you have a single branch of development (you could have multiple, but you don't need to)
  • your source is wherever you like it to be
  • two distinct build steps assemble the source for chrome and firefox
  • 2
    Now that I think about it thanks to your explanation, I feel like I am thinking of things in a very complex way. In reality I can have a python (or batch) script which will generate the appropriate structure for each extension type. So for Firefox I would run the script and it will move the files into the appropriate file structure. A lot of the extra fluff like the unique manifest files can be created dynamically as well. – Serguei Fedorov Apr 16 '15 at 20:07
  • @Serguei Indeed – ptyx Apr 16 '15 at 22:05
2

You might be trying to use git to handle a situation it was not intended to[citation needed], maybe a build script might be the answer.

If Chrome is flexible with the folder structure, you could just follow the folder structure required by Firefox. Have one branch for Chrome and another for Firefox to handle the distinct files, then later do a merged by a script to form a release version for each browser.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.