This is a git merge driver specific for Salesforce.com Metadata (Profiles, Permission Sets, Custom Labels).
The merge is done based on the nodes of the files, checking if any node changed in both the local copy and the branch we're trying to merge, and automatically merging whenever there is no conflict.
In the case of a node being modified in our local workspace and in the branch we try to merge, both nodes are marked with a conflict that specifies from which change the node comes, so it makes it easier to identify and resolve the conflict.
- sfdx-md-merge-driver
- Automatic Setup (recommended)
- Install as Dependency
- Uninstalling
- Commands
- Author
To start using it right away:
$ npx @kgossent/sfdx-md-merge-driver install --global
Or install it locally, per-project:
$ cd /path/to/git/repository
$ npx @kgossent/sfdx-md-merge-driver install
...And you're good to go!
$ npx @kgossent/sfdx-md-merge-driver install
$ git merge my-conflicting-branch
Conflicts Found: 2
Conflicts Found: 0
CONFLICT (content): Merge conflict in force-app/main/default/profiles/Admin.profile-meta.xml
Auto-merging force-app/main/default/profiles/Standard.profile-meta.xml
Automatic merge failed; fix conflicts and then commit the result.
To avoid regular npx
installs, consider installing the driver:
$ npm install -g @kgossent/sfdx-md-merge-driver
$ sfdx-md-merge-driver COMMAND
running command...
$ sfdx-md-merge-driver (-v|--version|version)
@kgossent/sfdx-md-merge-driver/0.1.29 win32-x64 node-v12.18.2
$ sfdx-md-merge-driver --help [COMMAND]
USAGE
$ sfdx-md-merge-driver COMMAND
...
To remove an installed merge driver, use sfdx-md-merge-driver uninstall
:
$ npx sfdx-md-merge-driver uninstall [--global] [--driver-name=sfdx-md-merge-driver]
Or remove the package:
$ npm uninstall -g sfdx-md-merge-driver
sfdx-md-merge-driver help [COMMAND]
sfdx-md-merge-driver install
sfdx-md-merge-driver join
sfdx-md-merge-driver merge
sfdx-md-merge-driver sort
sfdx-md-merge-driver uninstall
display help for sfdx-md-merge-driver
USAGE
$ sfdx-md-merge-driver help [COMMAND]
ARGUMENTS
COMMAND command to show help for
OPTIONS
--all see all commands in CLI
See code: @oclif/plugin-help
Set up the merge driver in the current git repository.
USAGE
$ sfdx-md-merge-driver install
OPTIONS
-d, --driver=driver
[default: sfdx-md-merge-driver merge -o %O -a %A -b %B -p %P] string to install as the driver in the git
configuration
-g, --global
install to your user-level git configuration
-h, --help
show CLI help
-n, --name=name
[default: sfdx-md-merge-driver] String to use as the merge driver name in your configuration.
-t, --files=*.profile|*.profile-meta.xml|*.permissionset|*.permissionset-meta.xml|*.labels|*.labels-meta.xml
[default: *.profile,*.profile-meta.xml,*.permissionset,*.permissionset-meta.xml,*.labels,*.labels-meta.xml]
Filenames that will trigger this driver.
See code: src/commands/install.ts
Additionally merge the files of same metadataType
USAGE
$ sfdx-md-merge-driver join
OPTIONS
-a, --algo=latest|meld [default: latest] algorithm for join, latest or meld
-h, --help show CLI help
-l, --loglevel=loglevel level of verbose details
-m, --meta=meta (required) path(s) to file(s) to join
-o, --output=output path to write output
-v, --verbose verbose mode
See code: src/commands/join.ts
Check for conflicts and merge them if possible.
USAGE
$ sfdx-md-merge-driver merge
OPTIONS
-a, --current=current (required) current version
-b, --other=other (required) other branches’ version
-h, --help show CLI help
-o, --ancestor=ancestor (required) ancestor’s version
-p, --output=output pathname in which the merged result will be stored
See code: src/commands/merge.ts
describe the command here
USAGE
$ sfdx-md-merge-driver sort
OPTIONS
-h, --help show CLI help
-l, --loglevel=loglevel level of verbose details
-m, --meta=meta (required) path(s) to file(s) to sort
-v, --verbose verbose mode
See code: src/commands/sort.ts
Remove a previously configured driver
USAGE
$ sfdx-md-merge-driver uninstall
OPTIONS
-g, --global install to your user-level git configuration
-h, --help show CLI help
-n, --name=name [default: sfdx-md-merge-driver] String to use as the merge driver name in your configuration.
See code: src/commands/uninstall.ts
- For easy key (api_key) values: the key is the unicity, the value is looked into for conflicts
- For almost easy key with value-block: unicity driven by a single key field and value block cannot be seperate, equivalent of previous point
- For composite key (multiple fields) with value or value-block: unicity created by a virtual concatenation of key fields, value or value-block is looked into for conflicts
- For indexed array of the previous scenarios: unicity is as previously but we have to include the index as a virtual value to recompose a properly ordered array in the end
Written by jayree
Based on code from Amguerrero's repository sfdc_merge and forks from Dhanielk and KevinGossentCap.
Node.js Installer framework based on code from Zkat's repository npm-merge-driver