Skip to content

Instantly share code, notes, and snippets.

@lsmag
Created February 27, 2019 22:04
Show Gist options
  • Save lsmag/5800c40602d9afd337c7d2f9c1189af1 to your computer and use it in GitHub Desktop.
Save lsmag/5800c40602d9afd337c7d2f9c1189af1 to your computer and use it in GitHub Desktop.
#!/bin/bash
xmain() {
local source_branch="$1"; shift
local source_commit=$(git merge-base HEAD "$source_branch")
git rebase -i \
--exec 'docker-compose run --rm magalu-entregas make lint' \
--exec 'docker-compose run --rm magalu-entregas make test' \
"$source_commit" \
--reschedule-failed-exec
}
print_help() {
echo "foo"
}
smart_rebase() {
local source_branch="$1"; shift
local commands="$@"
local source_commit=$(git merge-base HEAD "$source_branch")
git rebase -i "${commands[@]}" "$source_commit" --reschedule-failed-exec
}
main() {
local commands=()
local source_branch="$1"; shift
while test $# -gt 0; do
case "$1" in
-h|--help)
print_help
exit 0
;;
-x|--exec)
shift # consume the -x/--exec
commands+=(--exec "$1")
shift # consume the command itself
;;
esac
done
smart_rebase "$source_branch" "${commands[@]}"
}
main "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment