GithubHelp home page GithubHelp logo

dap's Introduction

Diff and Patch (dap)

badge

Diff and Patch (dap) is a tool inspired by https://meldmerge.org/ and https://github.com/google/diff-match-patch

Table of Contents

Purpose

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.

Workflow

  1. Determine if the files differ

  2. Present a diff to the user and determine if they want to patch the file

  3. Present a list of patches or chunks of diff and let the user decided which ones to apply

  4. Save the changes

Quick overview

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.

  1. 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
    ...

dap's People

Contributors

davidgamba avatar mgale avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

davidgamba

dap's Issues

Order of files feels backwards

When I call dap I expect: dap <source> <destination>, it expects dap <destination> <source>.

What is the rationale behind that?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.