add scripts for some restoring

This commit is contained in:
2023-07-24 01:57:30 -06:00
parent 809e4d1215
commit 37aa4e3899
2 changed files with 39 additions and 0 deletions

34
git-restore.sh Normal file
View File

@ -0,0 +1,34 @@
#!/bin/bash
# replace these with your own
GITEA_API_KEY=***API_token***
GITEA_API_ENDPOINT=https://git.sa.vin/api/v1
REPO_DIR=/home/mason/Desktop/gitea-repositories/masonite-studios #replace it with your old repo path
SSH_REPO=ssh://git@git.sa.vin:2222
USER=masonite-studios
for dir in $REPO_DIR/*.git; do
if [ -d "$dir" ]; then
# naming the repo
REPO=$(basename $dir .git)
# create repo in Gitea
#curl -H "content-type: application/json" -H "Authorization: token $GITEA_API_KEY" -X POST -d '{"Name":"'$REPO'","private":true}' $GITEA_API_ENDPOINT/user/repos
curl -H "content-type: application/json" -H "Authorization: token $GITEA_API_KEY" -X POST -d '{"Name":"'$REPO'","private":true}' $GITEA_API_ENDPOINT/orgs/$USER/repos
echo "Created $REPO in Gitea."
# change directory to old repo
cd $dir
# set new origin
git remote add origin $SSH_REPO/$USER/$REPO.git
git remote set-url origin $SSH_REPO/$USER/$REPO.git
# push all from old repo to Gitea
git push --all origin
# change back to home directory
cd ../
fi
done

5
gitea-api.sh Normal file
View File

@ -0,0 +1,5 @@
# Create a token
curl -X POST -H "Content-Type: application/json" -d '{"name":"test", "scopes": ["write:user","write:repository","write:organization"]}' -u payne8:***password*** https://git.sa.vin/api/v1/users/payne8/tokens
# Delete a token
curl -X DELETE -H "Content-Type: application/json" -u payne8:***password*** https://git.sa.vin/api/v1/users/payne8/tokens/test