init
This commit is contained in:
commit
abf5e06606
12 changed files with 425 additions and 0 deletions
48
10_update-repos.sh
Executable file
48
10_update-repos.sh
Executable file
|
@ -0,0 +1,48 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
REPO_LIST="./10_git-repos-source-list"
|
||||
DEST_DIR="./10_repos"
|
||||
|
||||
if [ ! -f "$REPO_LIST" ]; then
|
||||
echo "Error: $REPO_LIST not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "$DEST_DIR"
|
||||
|
||||
while IFS= read -r line; do
|
||||
line=$(echo "$line" | tr -d '\r\n' | sed 's/[[:space:]]*$//')
|
||||
|
||||
if [ -z "$line" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
if [[ ! "$line" =~ ^https?:// ]]; then
|
||||
echo "Skipping invalid URL: $line"
|
||||
continue
|
||||
fi
|
||||
|
||||
repo_name=$(basename "$line" .git)
|
||||
repo_path="$DEST_DIR/$repo_name"
|
||||
|
||||
echo "Processing: $line"
|
||||
|
||||
if [ -d "$repo_path" ]; then
|
||||
echo " Updating existing repo: $repo_name"
|
||||
cd "$repo_path"
|
||||
git fetch origin
|
||||
git reset --hard origin/main
|
||||
cd - > /dev/null
|
||||
else
|
||||
echo " Cloning new repo: $repo_name"
|
||||
git clone "$line" "$repo_path"
|
||||
fi
|
||||
|
||||
echo " Done: $repo_name"
|
||||
echo ""
|
||||
|
||||
done < "$REPO_LIST"
|
||||
|
||||
echo "All repositories updated successfully!"
|
Loading…
Add table
Add a link
Reference in a new issue