Skip to content

Instantly share code, notes, and snippets.

@obar1
Last active April 10, 2024 19:51
Show Gist options
  • Save obar1/771b1992368262737d9f25fcf17ce1c1 to your computer and use it in GitHub Desktop.
Save obar1/771b1992368262737d9f25fcf17ce1c1 to your computer and use it in GitHub Desktop.
update 0 to 100 repos
#!/bin/bash
set -x
function get_latest_main {
cd 0to100.git
pwd
git fetch
git checkout main
git pull
cd -
}
function update_code {
echo "$1" | tr '[:lower:]' '[:upper:]'
pwd
rm -rf "$1"/zero_to_one_hundred
cp -r 0to100.git/zero_to_one_hundred "$1"
}
function git_status {
echo "$1" | tr '[:lower:]' '[:upper:]'
cd "$1"
pwd
git status
git add . && git commit -m "wip" && git push
cd -
}
function update_f {
cp 0to100.git/"$1" "$2"
}
dirs_to_update=("0to100.datacamp.git" "0to100.gcloud.git" "0to100.oreilly.git" "kb.oreilly.git" "zero2hero.git")
# dirs_to_update=("kb.oreilly.git" "zero2hero.git") # test set
latest_files=(files Makefile main.py main_sb.py requirements-dev.txt requirements.txt runner.py setup.py)
get_latest_main
for d in "${dirs_to_update[@]}"; do
update_code "$d"
done
for d in "${dirs_to_update[@]}"; do
for f in "${latest_files[@]}"; do
update_f "$f" "$d"
done
done
for d in "${dirs_to_update[@]}"; do
git_status "$d"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment