Skip to content

Commit

Permalink
feat: create "permissive git diff" parameter
Browse files Browse the repository at this point in the history
Manage a new argument --permissivediff to add the following parameters to git diff call

[
    '--ignore-all-space',
    '--ignore-blank-lines',
    '--ignore-cr-at-eol',
    '--word-diff-regex',
]
It allows to avoid detecting as a difference the indentation/spaces stuff
  • Loading branch information
nvuillam authored and scolladon-sfdc committed Aug 30, 2021
1 parent 6b2adb4 commit 7c0fa4f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions messages/delta.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ module.exports = {
ignoreDestructiveFlag: 'ignore file to use',
apiVersionFlag: 'salesforce API version',
deltaFlag: 'generate delta files in [--output] folder',
permissivediffFlag:
'allow spaces, blank lines and other indentation stuff to NOT be considered as diff',
}
6 changes: 6 additions & 0 deletions src/commands/sgd/source/delta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ export default class SourceDeltaGenerate extends SfdxCommand {
description: messages.getMessage('sourceFlag'),
default: CliHelper.SOURCE_DEFAULT_VALUE,
}),
permissivediff: flags.boolean({
char: 'P',
description: messages.getMessage('permissivediffFlag'),
default: false,
}),
output: flags.filepath({
char: 'o',
description: messages.getMessage('outputFlag'),
Expand Down Expand Up @@ -78,6 +83,7 @@ export default class SourceDeltaGenerate extends SfdxCommand {
ignoreDestructive: this.flags['ignore-destructive'],
apiVersion: this.flags['api-version'],
repo: this.flags.repo,
permissivediff: this.flags.permissivediff,
generateDelta: this.flags['generate-delta'],
})
output.warnings = jobResult?.warnings?.map(warning => warning.message)
Expand Down
12 changes: 12 additions & 0 deletions src/utils/repoGitDiff.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ const lcSensitivity = {
}

module.exports = (config, metadata) => {
// If --permissivediff argument, allow spaces, blank lines and other indentation stuff to NOT be considered as diff
if (config.permissivediff === true) {
fullDiffParams.push(
...[
'--ignore-all-space',
'--ignore-blank-lines',
'--ignore-cr-at-eol',
'--word-diff-regex',
]
)
}
// Call git diff
const { stdout: diff } = childProcess.spawnSync(
'git',
[...fullDiffParams, config.from, config.to, config.source],
Expand Down

0 comments on commit 7c0fa4f

Please sign in to comment.