Last active
March 8, 2019 01:54
-
-
Save dmc-at-work/8265d61df3b4b8e07165681d46032880 to your computer and use it in GitHub Desktop.
Clone Multiple Git Repositories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################################################################ | |
# | |
# prepend | |
# sed -e s#^#prefix#g file.txt > new_file.txt | |
# sed -i s#^#prefix#g file.txt | |
# append | |
# sed -e s#$#suffix#g file.txt > new_file.txt | |
# sed -i s#$#suffix#g file.txt | |
# awk style | |
# awk '$0="prefix"$0' file > new_file | |
# awk '$0=$0"suffix"' file > new_file | |
################################################################################ | |
file=$1 | |
if [ ! -e $file ]; then | |
echo "File not found!" | |
exit 1 | |
else | |
echo "Processing $file..." | |
fi | |
cp "$file" "$file".repolist | |
sed -i 's#^#https://__scm-user__@__scm-cname__/__scm-project-path__/#g' "$file".repolist | |
sed -i 's#$#.git#g' "$file".repolist | |
################################################################################ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
################################################################################ | |
# multi-git-clone.sh | |
# $ ./multi-git-clone.sh <name-or-*>.repolist | |
# | |
# v20190307 | |
# dmc-at-work | |
# | |
# Pre-Tasks: | |
# - Templated .repolist file(s) can be replaced | |
# with known list of URLs/URIs | |
# - Or template can be ran through sed replace | |
# routines for the known URL/URI vars: | |
# [__scm-user__, __scm-cname__, __scm-project-path__] | |
# - sed -i "s#__scm-user__#$scm_user-var#g" sample.repolist | |
# - sed -i "s#__scm-cname__#$scm_cname#g" sample.repolist | |
# - sed -i "s#__scm-project-path__#$scm_pce_path#g" sample.repolist | |
# - Or template URL/URI vars can be replaced | |
# manually | |
################################################################################ | |
if [[ $# -eq 0 ]] ; then | |
echo 'Usage:' | |
echo '$ ./multi-git-clone.sh <name-or-*>.repolist' | |
exit 1 | |
fi | |
readarray urls <<< $( cat "$@" ) | |
for scm_url in ${urls[@]} | |
do | |
echo "Cloning $scm_url ..." | |
git clone $scm_url | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
################################################################################ | |
# repolist-variables-update.sh | |
# $ ./repolist-variables-update.sh <filename>.repolist | |
# | |
# v20190307 | |
# dmc-at-work | |
# | |
# Description: | |
# - Utility to update repolist scm vars | |
# - Use with existing environment variables or | |
# override with shell script exported environment variables | |
################################################################################ | |
if [[ $# -eq 0 ]] ; then | |
echo 'Usage:' | |
echo '$ ./repolist-variables-update.sh <filename>.repolist' | |
exit 1 | |
fi | |
filename=$1 | |
export scm_user={replace-with-user-string} | |
export scm_name={replace-with-host-string} | |
export scm_project_path={replace-with-path-string} | |
sed -i "s#__scm-user__#$scm_user#g" $filename | |
sed -i "s#__scm-cname__#$scm_cname#g" $filename | |
sed -i "s#__scm-project-path__#$scm_project_path#g" $filename |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://__scm-cname__/__scm-project-path__/01.git | |
https://__scm-cname__/__scm-project-path__/02.git | |
https://__scm-cname__/__scm-project-path__/03.git | |
https://__scm-cname__/__scm-project-path__/04.git | |
https://__scm-cname__/__scm-project-path__/05.git | |
https://__scm-cname__/__scm-project-path__/06.git | |
https://__scm-cname__/__scm-project-path__/07.git | |
https://__scm-cname__/__scm-project-path__/08.git | |
https://__scm-cname__/__scm-project-path__/09.git | |
https://__scm-cname__/__scm-project-path__/10.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://__scm-user__@__scm-cname__/__scm-project-path__/01.git | |
https://__scm-user__@__scm-cname__/__scm-project-path__/02.git | |
https://__scm-user__@__scm-cname__/__scm-project-path__/03.git | |
https://__scm-user__@__scm-cname__/__scm-project-path__/04.git | |
https://__scm-user__@__scm-cname__/__scm-project-path__/05.git | |
https://__scm-user__@__scm-cname__/__scm-project-path__/06.git | |
https://__scm-user__@__scm-cname__/__scm-project-path__/07.git | |
https://__scm-user__@__scm-cname__/__scm-project-path__/08.git | |
https://__scm-user__@__scm-cname__/__scm-project-path__/09.git | |
https://__scm-user__@__scm-cname__/__scm-project-path__/10.git |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Very nice! Thank you.