inital commit
This commit is contained in:
42
git/.local/bin/auto_clone
Executable file
42
git/.local/bin/auto_clone
Executable file
@@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
|
||||
token="$1"
|
||||
page=1
|
||||
project_dir="$HOME/projects"
|
||||
|
||||
base_url="https://gitea.finnvanreenen.nl/api/v1"
|
||||
|
||||
while [[ $page -lt 21 ]]
|
||||
do
|
||||
# echo
|
||||
echo "## get repo list page $page"
|
||||
repos="$(curl -X 'GET' "$base_url/user/repos?page=$page&token=$token" -H 'accept: application/json')"
|
||||
login="$(echo "$repos" | sed -e 's/^.*"login":"\([^"]*\)".*$/\1/')"
|
||||
|
||||
if [[ "$repos" != "[]" ]]
|
||||
then
|
||||
for repo in $(echo "$repos" | sed -e 's/^\[{//' -e 's/}]$//' -e 's/},{/\n/g' -e 's/%/%p/g' -e 's/ /%20/g')
|
||||
do
|
||||
repo_json="$(echo "$repo" | sed -e 's/%20/ /g' -e 's/%p/%/g')"
|
||||
full_name="$(echo "$repo_json" | sed -e 's/^.*"full_name":"\([^"]*\)".*$/\1/')"
|
||||
clone_url="$(echo "$repo_json" | sed -e 's/^.*"clone_url":"\([^"]*\)".*$/\1/')"
|
||||
echo
|
||||
echo "### ${full_name,,}"
|
||||
|
||||
if [ -d "$project_dir/${full_name,,}" ]
|
||||
then
|
||||
cd "$project_dir/${full_name,,}"
|
||||
# git fetch
|
||||
else
|
||||
url="$(echo "$clone_url" | sed "s|://|://$login:$token@|")"
|
||||
git clone "$url" "$project_dir/${full_name,,}"
|
||||
fi
|
||||
|
||||
done
|
||||
else
|
||||
echo "No more repositories found."
|
||||
page=999
|
||||
fi
|
||||
|
||||
page="$(( $page + 1 ))"
|
||||
done
|
||||
12
git/dot-gitconfig
Normal file
12
git/dot-gitconfig
Normal file
@@ -0,0 +1,12 @@
|
||||
[user]
|
||||
name = LailaTheElf
|
||||
email = mail@lailatheelf.nl
|
||||
signingKey = EB05B87D06C84E807C8D128B8A3EF0226518C12D
|
||||
|
||||
[commit]
|
||||
gpgsign = true
|
||||
|
||||
[init]
|
||||
defaultBranch = main
|
||||
[safe]
|
||||
directory = /opt/keys
|
||||
Reference in New Issue
Block a user