Open sivashankerN opened 6 years ago
New organization has been created https://github.com/vlabs-courses
Renamed organization name from https://github.com/vlabs-courses to https://github.com/vlabs-on-openedx
Follow the below script for cloning Github repositories using shell script
USAGE () {
echo ""
echo -e "ERROR : date
: Expects one argument. Please execute as given below \n"
echo "EXECUTION : date
: sh clone-repo.sh git-username"
echo "EXECUTION : date
: sh clone-repo.sh git-organization-name"
echo ""
}
if [ "$#" -ne 1 ]; then USAGE exit 1 fi
USER=$1; #Initialize the username or organization name BKP_DIR="/home/raghupathi/deleteme" #Give the base path where every repository is cloned GIT_REPO_INFO="git-repo-info.txt" #Variable contain the file name to hold all info related to git repo URL_TO_CLONE="url_to_clone.txt" #Varibale contain the file name to hold urls of all repo to be cloned REPOSITORY_NAMES="repository_names.txt" #Variable contain the file name to hold the names of all repositories
echo "INFO : date
: Cloning Started " > $BKP_DIR/clone_start_time.txt
curl "https://api.github.com/users/$USER/repos?per_page=1000" > $BKP_DIR/$GIT_REPO_INFO
grep '"message": "Not Found"' $BKP_DIR/$GIT_REPO_INFO > /dev/null
if [ $? -eq 0 ] ;
then
echo "ERROR : date
: Mentioned github username does not exist "
exit 1
fi
cat $BKP_DIR/$GIT_REPO_INFO | grep "clone_url" | awk '{print $2}' | sed 's/\"//g' | sed 's/,//g' > $BKP_DIR/$URL_TO_CLONE cat $BKP_DIR/$GIT_REPO_INFO | grep '"name"' | awk '{print $2}' | sed 's/\"//g' | sed 's/,//g' > $BKP_DIR/$REPOSITORY_NAMES
cd $BKP_DIR
cat $BKP_DIR/$URL_TO_CLONE | while read url
do
git clone $url
echo "" #Just for a blank line
done
cat $BKP_DIR/$REPOSITORY_NAMES | while read repo_name
do
cd $BKP_DIR/$repo_name
echo "INFO : date
: git pull for $repo_name : git pull
"
done
echo "INFO : date
: Cloning Done " > $BKP_DIR/clone_stop_time.txt
Create new organization - Only for vlabs-edx courses and move all course repositories from https://github.com/openedx-vlead to https://github.com/vlabs-courses