We fix the postupgrade script by doing two things:
(1) Only remove files in the theme folder if it is not a submodule. The
default for the jambo init command is to have theme folders added as
submodules. Before we were removing the .git folder which made it so
that we could not see the history of the theme folder. We can now see
the full theme git history after an upgrade.
(2) Merge the correct global_config files. Before, we were merging the
theme global_config.json pre-upgrade and post-upgrade. That is, we did
not touch the user's global_config.json. This is not the desired
behavior, and instead, we would like to see new fields from any new theme
global_config.json file in the user-defined config/global_config.json.
So we change the files being merged.
Note: This means that on postupgrade, we update the user's
config/global_config.json with any new fields. We do not delete any
fields.
Note: This does not touch legacy upgrades.
Add tests for postupgrade merge JSON to make sure we keep certain
assumptions about this global_config merge.
First, it should always give precedence to the original config.
Second, it should not delete any custom fields added to the
global_config.
Third, it should be completely additive and add new fields if they exist
in any of the configuration parameters.
J=SLAP-578
TEST=manual
npm test
Test on a completely new `jambo init` site with the HH theme. Try `jambo
upgrade` and make sure there are no errors. The error we don't want to
see is below.
```
fatal: Path 'themes/answers-hitchhiker-theme/global_config.json' exists on disk, but not in 'HEAD'.
Error: fatal: Path 'themes/answers-hitchhiker-theme/global_config.json' exists on disk, but not in 'HEAD'.
at GitExecutorChain.onFatalException (/Users/creotutar/test/jambo/test6/node_modules/simple-git/src/lib/runners/git-executor-chain.js:60:87)
at GitExecutorChain.<anonymous> (/Users/creotutar/test/jambo/test6/node_modules/simple-git/src/lib/runners/git-executor-chain.js:51:28)
at Generator.throw (<anonymous>)
at rejected (/Users/creotutar/test/jambo/test6/node_modules/simple-git/src/lib/runners/git-executor-chain.js:6:65)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
Error occurred on node version: v12.16.1
```
Used below command to clear the folder
```
rm -rf ./* && rm -rf .git* && jambo init && jambo import --theme
answers-hitchhiker-theme && npm install && git add -A && git commit -m
"init"
```