I'm trying to set up a macro to set up git repo for version control, so that I don't have to resort to manual terminal commands every time. Commit & push scripts are ready and working, it's initialising a new git repo that gives me grief:
The idea is that a script will perform 4 functions:
- Initialise a git repo at the same directory your file is saved
- Clone a remote repo (I have a base repo with scripts/packages I want present into all tex projects I create)
- Create a new remote repo (using Node GH) and assign it as the origin (basically re-creating the ability to fork a repo from yourself via command line)
- Commit and push all files to the new remote repo.
Here's my code:
%SCRIPT
buildManager.runCommand("git init", editor.fileName());
buildManager.runCommand("gh re --new " + editor.fileName() +
" --type private", editor.fileName());
buildManager.runCommand("git clone https://github.com/example/example.git "
+ editor.fileName(), editor.fileName());
buildManager.runCommand("git remote set-url origin https://github.com/example/"
+ editor.fileName(), editor.fileName());
buildManager.runCommand("git push origin master", editor.fileName());
buildManager.runCommand("git push --all", editor.fileName())
The problem is I think TeXStudio doesn't perform the commands in order of appearance, which results in some commands failing (sample output at the bottom). Is there a way to define the order the commands are performed? Alternatively, can I do the same by calling a bash script (where I can definitely define the order) and pass the working dir through the macro?
Log output:
Process started: git push --all
fatal: Not a git repository (or any of the parent directories): .git
Process exited with error(s)
fatal: Not a git repository (or any of the parent directories): .git
Process exited with error(s)
fatal: Not a git repository (or any of the parent directories): .git
Process exited with error(s)
fatal: could not create work tree dir '/NewProject': Permission denied
/.git: Permission denied
Process exited with error(s)
Process exited with error(s)
Process exited normally