Add helper script for interoperability with Overleaf

This commit is contained in:
Filip Gralinski 2021-10-02 11:22:02 +02:00
parent 9cd44022ec
commit 65521e35df

View File

@ -0,0 +1,61 @@
#!/bin/bash -x
echo "Setting up interoperability with Overleaf..."
echo "Note that you need ability to clone repos from Overleaf."
original_git_url=$(git remote get-url origin)
here_dir=$(basename $PWD)
make
make source-pack
source_pack={{cookiecutter.paper_id}}.zip
echo "Go to Overleaf, click New Project / Upload Project,"
echo "then upload $source_pack from here ($(pwd)/$source_pack)"
echo ""
echo "When it is uploaded, click Menu / Git, copy the URL"
echo "(something like https://git.overleaf.com/123456789ec0830001af836f),"
echo "paste here and press ENTER"
read
overleaf_git_url=$REPLY
overleaf_git_id=$(basename $overleaf_git_url)
cd ..
git clone $overleaf_git_url
cd $overleaf_git_id
git remote add overleaf $overleaf_git_url
git remote set-url origin $original_git_url
git config credential.helper "cache --timeout=10000000"
cp ../$here_dir/.cookiecutter.yml .
git add .cookiecutter.yml
git commit -m 'Back cookiecutter config'
cookiecutter https://git.wmi.amu.edu.pl/filipg/paper-cutter.git --checkout master --output-dir .. --config-file .cookiecutter.yml --no-input --overwrite-if-exists
git add --all
git commit -m 'Bring back all the files'
perl -pne 's/OVERLEAF_GIT_URL=/OVERLEAF_GIT_URL='$overleaf_git_url'/' -i helpers/vars
git push overleaf master
git push origin master
cd ..
backup_dir=${here_dir}-backup
mv $here_dir ${here_dir}-backup
mv $overleaf_git_id $here_dir
echo "DONE"
echo "Left ${here_dir}-backup, now type 'cd ..' and you can remove it"