1

I am using Git for our code repository.
Each repo we got consist of master, development and fix branch.

The master we use that for our code that resides in production, while development is our report for our development changes.
My prd and dev site have different path.

How do you configure that in order to make every deployment to prd or dev seamless using different branch?
Right now, I have a path in my packages.json.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
Hawk
  • 514
  • 1
  • 7
  • 22

1 Answers1

0

The idea would be to not version package.json (keep it private), but to generate it (with the right value in it).

The generation script will determine the name of the checked out branch with:

branch=$(git rev-parse --symbolic --abbrev-ref HEAD)

That means you could:

  • version only a template file package.json.tpl
  • version value files named after the branches: version.dev, version.master: since they are different, there is no merge issue when merging or switching branches.

Finally, you would register (in a .gitattributes declaration) a content filter driver.

smudge (image from "Customizing Git - Git Attributes", from "Pro Git book")

The smudge script, associated to the template file (package.json.tpl), would generate (automatically, on git checkout) the actual package.json file by looking values in the right version.<branch> value file.
The generated actual package.json file remains ignored (by the .gitignore).

See a complete example at "git smudge/clean filter between branches".

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250