Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function _checkout() {
- clear
- # Determine the name of the new branch
- if [ -z "$1" ]; then
- new_branch="$(__git_both_repo branch | grep '^\(*\|\s\)' | sort -u | fzf)"
- new_branch="${new_branch:2}"
- [ -z "$new_branch" ] && exit
- else
- new_branch="$1"
- fi
- # Base branch (master, saas-15, ...)
- base_branch="$(__get_base_branch "$new_branch")"
- # Current branch
- current_branch="$(__get_current_branch)"
- echo -e "Checkout branch $GREEN$new_branch$DEFAULT..."
- repositories="$ODOO_PATH $ENTERPRISE_PATH"
- for repo in $repositories; do
- repo_name="$(__get_repo_name "$repo")"
- # Stash
- __save-stash $repo $repo_name $current_branch
- # Check existance of the branch
- git -C $repo rev-parse --verify "$new_branch" > /dev/null 2>&1
- if [[ "$?" != "0" ]]; then
- echo -e "[$BLUE$repo_name$DEFAULT] Would you like to create $GREEN$new_branch$DEFAULT ? y/n "
- read create
- if [[ "$create" == "y" ]]; then
- remote="$(git -C $repo remote -v | grep -m 1 -v dev | awk '{print $1}')"
- git -C $repo branch $new_branch $remote/$base_branch --no-track
- else
- new_branch=$current_branch
- fi
- fi
- # Checkout
- echo -e "[$BLUE$repo_name$DEFAULT:$GREEN$new_branch$DEFAULT] Checkout..."
- git -C $repo checkout $new_branch > /dev/null 2>&1
- # Remove files
- __clean-repo $repo $repo_name $new_branch
- # Apply stash
- __apply-stash $repo $repo_name $new_branch
- done
- echo -e "Checkout branch $GREEN$new_branch$DEFAULT done"
- _git status
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement