gruntwork-io / git-xargs

git-xargs is a command-line tool (CLI) for making updates across multiple Github repositories with a single command.
https://blog.gruntwork.io/introducing-git-xargs-an-open-source-tool-to-update-multiple-github-repos-753f9f3675ec
Apache License 2.0
935 stars 62 forks source link

Fix stdout/stderr handling #27

Closed brikis98 closed 3 years ago

brikis98 commented 3 years ago

This PR fixes #24. It ensures that git-xargs always logs stdout / stderr from the script, even if the script exits with an error. I've added a test for this too.

Other tweaks in this PR:

  1. Refactor executeCommand to only run the command. This makes it easier to test this method.
  2. Move the git add logic that used to be in executeCommand into commitLocalChanges. This is the more logical home for it.
  3. If the work tree reports that the status is clean, don't try to commit anything in commitLocalChanges. Previously, the work tree status was only checked in executeCommand, and commitLocalChanges would try to commit whether or not the status was clean, which was probably a no op, but doesn't seem right.
  4. Remove some unused test functions.