Skip to content

Instantly share code, notes, and snippets.

@inhere
Created July 6, 2019 02:44
Show Gist options
  • Save inhere/cac157d0d4b1fdba63be27d9d65a2613 to your computer and use it in GitHub Desktop.
Save inhere/cac157d0d4b1fdba63be27d9d65a2613 to your computer and use it in GitHub Desktop.
Add the remote repository address of each component to the local remote
#!/usr/bin/env bash
#set -e
# import common functions
source "$(dirname $0)/common-func.sh"
binName="bash $(basename $0)"
if [[ -z "$1" ]]
then
echo "Add the remote repository address of each component to the local remote"
echo -e "Usage:\n $binName NAME(S)"
echo "Example:"
echo " $binName http-server"
echo " $binName http-server http-message"
exit 0
fi
# update one
if [[ "$1" != "all" ]]; then
COMPONENTS=$@
else
COMPONENTS=$(ls src/)
fi
REMOTE_PREFIX='[email protected]:swoft-cloud/swoft-'
echo "Will added components:"
echo " " ${COMPONENTS}
# git remote add stdlib http://github.com/swoft-cloud/swoft-stdlib.git
# git remote add stdlib [email protected]:swoft-cloud/swoft-stdlib.git
# git subtree add --prefix=src/stdlib stdlib master
# git subtree pull --prefix=src/stdlib stdlib master
# git subtree push --prefix=src/stdlib stdlib master
for lbName in ${COMPONENTS} ; do
colored_text "Check sub-component remote"
yellow_text "> git remote -v | grep ${lbName}"
REMOTE_INFO=`git remote -v | grep ${lbName}`
if [[ -n "$REMOTE_INFO" ]]; then
colored_text "${lbName}: has been add remote, skip add"
continue
fi
cyan_text "\n======> Add the project:【${lbName}】"
yellow_text "> git remote add ${lbName} ${REMOTE_PREFIX}${lbName}.git"
git remote add ${lbName} ${REMOTE_PREFIX}${lbName}.git
done
colored_text "\nAdd Remote Completed!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment