Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

promise: introduce promises to track success or error #1666

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Commits on Feb 17, 2024

  1. promise: add promise pattern to track success/error from operations

    Introduce a promise paradigm. A promise starts off in the pending state,
    and represents an asynchronous (or synchronous) action that will
    eventually end in either a successful result or a failure result. If a
    failure result, an error message may be provided.
    
    This allows us to represent tasks which may fail, while deferring any
    control flow actions or error printing that may occur in relation to
    said task.
    
    Signed-off-by: Philip Peterson <philip.c.peterson@gmail.com>
    philip-peterson committed Feb 17, 2024
    Configuration menu
    Copy the full SHA
    be270db View commit details
    Browse the repository at this point in the history
  2. apply: use new promise structures in git-apply logic as a proving ground

    Uses the new promise paradigm in a simple example with git apply and git
    am. Several operations that may produce errors are encapsulated in a
    promise, so that any errors may be captured and handled according to how
    the caller wants to do so.
    
    As an added bonus, we can see more context in error messages now, for
    example:
    
    % git apply -3 garbage.patch
    error:
    	could not find header
    caused by:
    	no lines to read
    
    Signed-off-by: Philip Peterson <philip.c.peterson@gmail.com>
    philip-peterson committed Feb 17, 2024
    Configuration menu
    Copy the full SHA
    677da78 View commit details
    Browse the repository at this point in the history
  3. apply: update t4012 test suite

    The test suite matched against a regex that expected the entire errored
    output to end before the additional context added to `git apply`.
    
    Signed-off-by: Philip Peterson <philip.c.peterson@gmail.com>
    philip-peterson committed Feb 17, 2024
    Configuration menu
    Copy the full SHA
    2da1b65 View commit details
    Browse the repository at this point in the history
  4. apply: pass through quiet flag to fix t4150

    This test was failing because it expects the invocation of `git apply`
    to be silent. Because previous patches introduce verbosity where
    previously there was a silent error (in the form of a return code), this
    adds an opportunity for a bug to become visible. The bug is in the way
    `git am` invokes `git apply`, not passing through --quiet when it is
    specified.
    
    Signed-off-by: Philip Peterson <philip.c.peterson@gmail.com>
    philip-peterson committed Feb 17, 2024
    Configuration menu
    Copy the full SHA
    c0d670d View commit details
    Browse the repository at this point in the history
  5. am: update test t4254 by adding the new error text

    The old error text was shorter than the new, so this just adds the new
    context message to the expected text.
    
    Signed-off-by: Philip Peterson <philip.c.peterson@gmail.com>
    philip-peterson committed Feb 17, 2024
    Configuration menu
    Copy the full SHA
    c6cbb7b View commit details
    Browse the repository at this point in the history