From 65521e35dfe1f4b1313eefbb07317a9d671966cb Mon Sep 17 00:00:00 2001 From: Filip Gralinski Date: Sat, 2 Oct 2021 11:22:02 +0200 Subject: [PATCH] Add helper script for interoperability with Overleaf --- .../helpers/set-up-overleaf.sh | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100755 {{cookiecutter.paper_repo_name}}/helpers/set-up-overleaf.sh diff --git a/{{cookiecutter.paper_repo_name}}/helpers/set-up-overleaf.sh b/{{cookiecutter.paper_repo_name}}/helpers/set-up-overleaf.sh new file mode 100755 index 0000000..954d761 --- /dev/null +++ b/{{cookiecutter.paper_repo_name}}/helpers/set-up-overleaf.sh @@ -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"