Fix gitlab shell test preparation reset method
Created by: cirosantilli
Bug introduced by self at: https://github.com/gitlabhq/gitlabhq/pull/7823
Before this PR, the test gitlab shell under tmp/tests/gitlab-shell will not correctly fetch new commits if necessary when it exists already (the cache was introduced on the PR that causes this problem: before it would always get removed and cloned).
This happens because the shell.rake sh reset line I wrote was completely wrong because:
- bad understanding of
git reset --hard: if there is no reference,reset --hard $()will do justgit reset --hard, which is valid, and does not activate the|| - bad understanding of precedence:
true || echo a && echo btranslates to(true || echo a) && echo b, so thefetchpart was never done!
Now it works, but is a monster expression. We could split this up into multiple system calls, but that would break the current convention of using sh.
This was extracted from: https://github.com/gitlabhq/gitlabhq/pull/8086