-
-
Save Jim-Holmstroem/fd11844c83d91052840a to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash | |
export GIT_FLAGS=$* | |
OLD_BRANCH="master" # $(git $GIT_FLAGS rev-parse --abbrev-ref HEAD) | |
echo $OLD_BRANCH | |
TEMP_BRANCH="deis_build" | |
git $GIT_FLAGS branch --force $TEMP_BRANCH && git $GIT_FLAGS checkout --force $TEMP_BRANCH | |
git $GIT_FLAGS submodule status | cut -d' ' -f3 | xargs --no-run-if-empty -I{} bash -c "git $GIT_FLAGS config -f .git/config --remove-section submodule.{}" && find -type f -name .git -o -type f -name .gitmodules | xargs --no-run-if-empty rm -f && rm -rf .git/modules/* && rm -f .git/index && git $GIT_FLAGS add -A && git $GIT_FLAGS commit -m"flattened" && git $GIT_FLAGS push deis $TEMP_BRANCH:master --force | |
MAIN_EXIT_CODE=$? | |
#cleanup | |
git $GIT_FLAGS checkout --force $OLD_BRANCH | |
git $GIT_FLAGS branch -D $TEMP_BRANCH | |
git $GIT_FLAGS submodule update --init --recursive | |
exit $MAIN_EXIT_CODE |
converted https://github.com/Jim-Holmstroem/submoduleexperiment
to without submodules and pushed to
simulated DEIS repo: https://github.com/Jim-Holmstroem/submoduleexperiment_flat/tree/test_flat3
I tried to make it work even if the last run of it leaved it in a bad state, but I leave no guarantees.
Note that this command will remove any uncommited files (and probably unstaged as well)
adds support for push_submodule_to_DEIS.sh -C "gitrepo"
(or any arbitrary general git argument) but it should still be backwards compat
xargs --no-run-if-empty
always rm -f
incase missing
how do you make this always work again, despite what state it was left in last time?
should always be used with a "wipe clean and re-clone" policy so that isn't effected by the previous state (especially after fails)
https://gist.github.com/Jim-Holmstroem/47b22b9bc7712d607360