Files
php-flasher/bin/split
T
2024-04-09 07:57:01 +00:00

64 lines
1.8 KiB
Bash
Executable File

#!/usr/bin/env bash
# Set the "errexit" options
set -o errexit
# Define colors and emoji for better visual feedback
INDIGO='\033[0;94m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
CHECK_MARK="✅"
CROSS_MARK="❌"
# Define remotes
REMOTES=(
'src/Prime:flasher'
'src/Laravel:flasher-laravel'
'src/Symfony:flasher-symfony'
'src/Toastr/Prime:flasher-toastr'
'src/Toastr/Laravel:flasher-toastr-laravel'
'src/Toastr/Symfony:flasher-toastr-symfony'
'src/Notyf/Prime:flasher-notyf'
'src/Notyf/Laravel:flasher-notyf-laravel'
'src/Notyf/Symfony:flasher-notyf-symfony'
'src/SweetAlert/Prime:flasher-sweetalert'
'src/SweetAlert/Laravel:flasher-sweetalert-laravel'
'src/SweetAlert/Symfony:flasher-sweetalert-symfony'
'src/Noty/Prime:flasher-noty'
'src/Noty/Laravel:flasher-noty-laravel'
'src/Noty/Symfony:flasher-noty-symfony'
)
# Define a function to split and push code to a remote repository
function split() {
local prefix_and_remote="$1"
local prefix="${prefix_and_remote%:*}"
local remote="${prefix_and_remote#*:}"
# Add remote if it does not exist (ignoring errors silently)
if git remote add "$remote" "git@github.com:php-flasher/$remote.git" 2>/dev/null; then
echo -e "${GREEN}Added remote ${INDIGO}$remote${NC} ${CHECK_MARK}"
fi
# Split the code using the splitsh-lite utility
SHA1=$(./bin/splitsh-lite --prefix="$prefix")
# Push the code to the specified remote repository
git push "$remote" "$SHA1:refs/heads/main" -f
}
# Pull the latest code from the origin repository
echo -e "${INDIGO}Pulling the latest code from the origin repository...${NC}"
git fetch origin main
# Iterate over the remotes and split and push the code
for remote in "${REMOTES[@]}"; do
split "$remote"
done
echo -e "${GREEN}All done!${NC} ${CHECK_MARK}"