Also ensure the repository doesn't get updated to an invalid state in those failure cases. Closes #5538
This change fixes issues with ps:rebuild not working as expected - essentially ignoring files in the repo - as well as adds tests. Closes #5518