Raise error when git command fails

What does this MR do and why?

Describe in detail what your merge request does and why.

Content

  • Raise error when git command fails

This code update enhances the error handling and retry mechanisms for interacting with remote Git repositories. It introduces a new context for the Retriable gem, specifically for Git operations, to better handle connection errors. Additionally, it improves the error messages and status reporting for Git commands, making it easier for developers to debug and troubleshoot issues.

  • Create two new error classes CannotPushError and RemoteConnectionError.
  • Instead of failing silently, push method raises CannotPushError
  • Some improvements to self.run_git:
    • Detect connection errors.
    • In case of connection errors, use Retriable to overcome intermittent network or server issues.
    • Otherwise, return cmd_output and response_status, same as the moment, to let the caller decides what to do next.
  • Add a new Retriable context named git.
  • Add corresponding rspec tests.
  • Remove unused OutOfSyncError class.
  • Small updates/corrections to README.

Ref: gitlab-com/gl-infra/delivery#20390 (closed)

Edited by Dat Tang

Merge request reports

Loading