Thank you for trying the new tool, @nok.
First, to explain how it currently works:
It clones the repo into wherever you are running it from.
It first checks whether the directory you’re in is already a clone you’re wanting to make and then it doesn’t clone, but re-uses the current checkout. the logic is to compare the output of:
git config --get remote.origin.url
with the url you are asking for, so for example if I’m inside the original fastai
repo, the above command will return:
git@github.com:fastai/fastai.git
but if I’m asking for the fork of the same, which in my case would be git@github.com:stas00/fastai.git
, then it can’t reuse that checkout and must make a new one. And so it does.
However if I’m already inside a checkout that matches: git@github.com:stas00/fastai.git
and I am invoking tools/fastai-make-pr-branch
for the same repo, it will not do a new checkout and use the current one instead.
Now to how we can improve usability. I think the issue is that when you call it from the fastai repo, with tools/fastai-make-pr-branch
- that’s where it will create the new clone. So ideally it should not be called it that way, but as explained here: https://docs-dev.fast.ai/git.html#helper-program
curl -O https://raw.githubusercontent.com/fastai/fastai/master/tools/fastai-make-pr-branch
chmod a+x fastai-make-pr-branch
./fastai-make-pr-branch https your-github-username fastai new-feature
another approach is to position yourself into the base directory you want the clone to happen in:
cd fastai
cd ..
fastai/tools/fastai-make-pr-branch https your-github-username fastai new-feature ../put-it-here
or put the script somewhere in your $PATH
, so that you could invoke it from anywhere.
or we should instrument it to have an extra argument so that the user can specify where the output should go. So say if you do call it from the fastai
checkout folder you could say:
cd fastai
tools/fastai-make-pr-branch https your-github-username fastai new-feature ../put-it-here
Thoughts?