Skip to content

Commit

Permalink
feat: migrate from groovy to node.js script
Browse files Browse the repository at this point in the history
  • Loading branch information
jayree committed Oct 27, 2019
1 parent f6219de commit b525c45
Show file tree
Hide file tree
Showing 9 changed files with 2,812 additions and 2,814 deletions.
18 changes: 18 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"env": {
"es6": true,
"node": true
},
"extends": ["standard"],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"rules": {
"no-console": "off"
}
}
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"trailingComma": "none",
"singleQuote": true,
"semi": false
}
50 changes: 33 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<!-- [![npm](https://img.shields.io/jayree/v/sfdx-merge-driver.svg)](https://npm.im/sfdx-merge-driver) [![license](https://img.shields.io/jayree/l/sfdx-merge-driver.svg)](https://npm.im/sfdx-merge-driver) [![Travis](https://img.shields.io/travis/jayree/sfdx-merge-driver.svg)](https://travis-ci.org/jayree/sfdx-merge-driver) [![AppVeyor](https://ci.appveyor.com/api/projects/status/github/jayree/sfdx-merge-driver?svg=true)](https://ci.appveyor.com/project/jayree/sfdx-merge-driver) [![Coverage Status](https://coveralls.io/repos/github/jayree/sfdx-merge-driver/badge.svg?branch=latest)](https://coveralls.io/github/jayree/sfdx-merge-driver?branch=latest) -->

# sfdx-merge-driver(1) -- Salesforce Metadata Specific Git Merge Driver
# sfdx-merge-driver(1) -- Salesforce Metadata Specific Git Merge Driver

This is a git merge driver specific for Salesforce.com Metadata.

Now supports:
* Profiles
* Permission Sets
* Custom Labels

- 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 merging automatically whenever there is no conflict.

Expand All @@ -21,11 +23,17 @@ $ npx sfdx-merge-driver install --global
```

**Or** install it locally, per-project:

```
$ cd /path/to/git/repository
$ npx sfdx-merge-driver install
```

...And you're good to go!

<!-- Next time your lockfile has a conflict, it will be automatically fixed. You
don't need to do anything else. -->

### Example

```
Expand All @@ -40,7 +48,8 @@ Automatic merge failed; fix conflicts and then commit the result.

### Advanced

The following section is only for advanced configuration of the driver if you have specific needs.
The following section is only for advanced configuration of the driver if you
have specific needs.

#### Setup Options

Expand All @@ -56,27 +65,32 @@ The following section is only for advanced configuration of the driver if you ha

To avoid regular `npx` installs, consider installing the driver:

`$ yarn install [-g|--save-dev] npm-merge-driver`
`$ yarn [global|--dev] add sfdx-merge-driver`

#### Manual Setup (advanced):

`sfdx-merge-driver` requires two git configurations to work: a git configuration to add the driver to git, which is by default your local `.git/config` file, and a `gitattributes(5)` configuration, which is by default your local `.git/info/attributes`.
`sfdx-merge-driver` requires two git configurations to work: a git configuration
to add the driver to git, which is by default your local `.git/config` file, and
a `gitattributes(5)` configuration, which is by default your local
`.git/info/attributes`.

If you **do not** want `sfdx-merge-driver` to install itself for you:

Copy the `sfdx_merge.groovy` script and the directory `conf/` into `.git/scripts/sfdx-merge/` (create this directory if it doesn't exist yet).
Add the driver to `.git/config`:

Then edit the `.git/config` file and add the following lines:
```
[merge "sfdx-merge-driver"]
name = A custom merge driver for Salesforce profiles
driver = groovy .git/scripts/sfdx-merge/sfdx_merge.groovy %O %A %B .git/scripts/sfdx-merge
recursive = binary
$ git config merge."sfdx-merge-driver".name \
"A custom merge driver for Salesforce profiles"
$ git config merge."sfdx-merge-driver".driver \
"npx sfdx-merge-driver merge %O %A %B %P"
$ git config merge."sfdx-merge-driver".recursive \
"binary"
```

This will configure the merge driver, and configure it to run the groovy script, the merges of the metadata.

Then add the following lines to `.gitattributes` or `.git/info/attributes` (create this file if it doesn't exist yet):
Add the relevant attributes to `.gitattributes` or `.git/info/attributes`:

```
*.profile merge=sfdx-merge-driver
*.profile-meta.xml merge=sfdx-merge-driver
Expand All @@ -89,10 +103,11 @@ Then add the following lines to `.gitattributes` or `.git/info/attributes` (crea
This will instruct git that all the Salesforce files should be merged using the new merge drivers.
You can also choose which metadata you want to use this driver to.

#### Configure the driver
<!-- #### Configure the driver
The merge driver uses the configuration in the file `.git/scritps/sfdx-merge/conf/merge-<metadataType>-config.json` to know what nodes to merge and how to identify if the nodes are the same node and if they are equal between the branches.
If a node type is not configured there, the merge driver will choose the one in the current branch.
-->

#### Uninstalling

Expand All @@ -103,11 +118,12 @@ $ npx sfdx-merge-driver uninstall [--global] [--driver-name=sfdx-merge-driver]
```

## AUTHOR

Based on code from [Amguerrero's](https://github.com/amguerrero) repository [sfdc_merge](https://github.com/amguerrero/sfdc_merge)

Installer based on code from [Zkat's](https://github.com/zkat) repository [npm-merge-driver](https://github.com/npm/npm-merge-driver)

## SEE ALSO

* `git-config(1)`
* `gitattributes(5)`
- `git-config(1)`
- `gitattributes(5)`
2 changes: 1 addition & 1 deletion conf/merge-profile-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"equalKeys": ["field", "editable", "hidden", "readable"]
},
"layoutAssignments": {
"exclusiveUniqueKeys": [["recordType"], ["layout"]],
"exclusiveUniqueKeys": ["recordType", "layout"],
"equalKeys": ["layout", "recordType"]
},
"loginHours": {
Expand Down
Loading

0 comments on commit b525c45

Please sign in to comment.