diff options
author | Amit Kucheria <amit.kucheria@linaro.org> | 2018-04-23 13:59:09 +0530 |
---|---|---|
committer | Daniel Lezcano <daniel.lezcano@free.fr> | 2018-04-23 11:04:53 +0200 |
commit | 937518cbe66b380642c79d059a5b48510c776663 (patch) | |
tree | 81a46029cac04b614a7bfbd8835e38e0311f837e | |
parent | 59bbd42e0a6cfd17fcf570d2d4c6c78305ed52c7 (diff) |
ci-merge: handle the case of a dirty local git tree
We can't proceed with a local tree that has any changes. Either offer to
clean them out, or abort and let the user clean them.
Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@free.fr>
-rwxr-xr-x | ci-merge | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -284,6 +284,30 @@ baseline_branch_setup() { ###################################################################### # +# Ensure that the local repo is clean +# +clean_local_repo() { + if [[ $(git status --porcelain) ]]; then + # Changes + echo "Local changes present" + git status --porcelain + echo -n "Clean it [Y/n]? " + read RES + if [ "$RES" == "Y" -o "$RES" == "y" -o "$RES" == "" ]; then + git clean -df + git reset --hard + else + echo "Please clean the repo before proceeding. Aborting." + exit 1 + fi + else + # No changes + echo "Local tree is clean" + fi +} + +###################################################################### +# # This is the global setup entry calling the different setup functions. # It ensures they are called in the right order. # !! Make sure to not change the order without double checking the !! @@ -300,6 +324,8 @@ do_setup() { config_setup baseline_branch_setup + + clean_local_repo } ###################################################################### |