Diff and Patch (dap) is a tool inspired by https://meldmerge.org/ and https://github.com/google/diff-match-patch
dap was created while working with mono repos and changes need to be promoted between file system folders instead of a branch or tag. It is designed to allow the user to pull in specific change sets between the files instead of a full copy paste or rsync operation.
If a difference between files exist a diff is displayed and the user is asked if they want to review and apply patches. If the user says no nothing happens and the operation is repeated for the next file. If the user says yes then the differences are broken up into chunks, a.k.a patches. Then each patch is reviewed and can either be applied or skipped.
dap requires 2 command line arguments, the first argument is the file or directory that should be patched, the location you want to push the changes into. The 2nd argument is the file or directory that you want to pull from.
The --dry-run option performs all the steps and confirmations with the exception of writing to the file system.
-
Using dap:
Show help$ ./dap --help NAME: dap - Transforms <original> into <desired_changes>. Said another way, brings changes into <original> from <desired_changes>. Example: ./dap original desired_changes SYNOPSIS: dap [--debug] [--dry-run] [--follow-sym-links] [--help|-h|-?] [--ignore-paths <string>]... [--include-hidden] [--report-only|-q] [--version|-V] <original> <desired_changes> OPTIONS: --debug (default: false) --dry-run Dry-run skips updating the underlying file contents (default: false) --follow-sym-links Follow symlinks (default: false) --help|-h|-? (default: false) --ignore-paths <string> Excludes pathnames from directory search, providing a value overrides the defaults of .git and .terraform (default: []) --include-hidden Include hidden files and directories (default: false) --report-only|-q Report only files that differ (default: false) --version|-V (default: false)
Report changes only$ ./dap --report-only tests/smalldiff/t1.txt tests/smalldiff/t2.txt Files tests/smalldiff/t1.txt and tests/smalldiff/t2.txt differ
Diff and patch a file$ ./dap --dry-run tests/smalldiff/t1.txt tests/smalldiff/t2.txt ##################################################### #DiffOutPut: Appling diff to: tests/smalldiff/t1.txt from: tests/smalldiff/t2.txt --- - nodes_group_count = 1 - node_replica_count = 1 + nodes_group_count = 2 + node_replica_count = 2 --- - node_type = "cache.t3.small" + node_type = "cache.m5.large" --- - engine_version = "5.0.6" - at_rest_encryption = true + engine_version = "5.0.8" + at_rest_encryption = false --- - visibility_timeout_seconds = 600 + visibility_timeout_seconds = 1200 --- ##################################################### Review patches and apply them? (y/n):y ##################################################### #PatchOutPut: Appling patch to: tests/smalldiff/t1.txt @@ -32,58 +32,58 @@ - nodes_group_count = 1 - node_replica_count = 1 + nodes_group_count = 2 + node_replica_count = 2 ##################################################### Apply patch? (y/n):n ##################################################### #PatchOutPut: Appling patch to: tests/smalldiff/t1.txt @@ -332,48 +332,48 @@ - node_type = "cache.t3.small" + node_type = "cache.m5.large" ##################################################### Apply patch? (y/n):n ##################################################### #PatchOutPut: Appling patch to: tests/smalldiff/t1.txt @@ -584,67 +584,68 @@ - engine_version = "5.0.6" - at_rest_encryption = true + engine_version = "5.0.8" + at_rest_encryption = false ##################################################### Apply patch? (y/n):y ##################################################### #PatchOutPut: Appling patch to: tests/smalldiff/t1.txt @@ -1179,44 +1179,45 @@ - visibility_timeout_seconds = 600 + visibility_timeout_seconds = 1200 ##################################################### Apply patch? (y/n):y Diffs: 13, Patches: 2, Applied: 2, Failed: 0 Dry-run enabled, skipping file writes: tests/smalldiff/t1.txt Scanned: Files: 2 Directories: 0 Diffs: 1 Patched: 2 Skipped: 0 Errors: 0 Runtime: 7.156947108s
Diff and patch a directory$ ./dap tests/smalldiff tests/smalldiff ...