-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
I recently started working with Windows more and interacting with Git for Windows more and got to thinking about how to make it easier for Windows users to use git-filter-repo and get the full experience since installing it has proved problematic for Windows users. I would like to propose a small shim installed at /usr/bin/python and /usr/bin/python3 that would make using git-filter-repo work like it does on a UNIX install of git.
I have a rough draft here:
#!/bin/bash
# Look for all `python` commands in ${PATH}
found_pythons=($(type -ap python 2>/dev/null))
# Look for a valid python interpreter
for python in "${found_pythons[@]}"
do
# Make sure we don't call ourselves Check that we aren't running the Microsoft Store shortcut
if [[ ! ${python} =~ (\/usr)?\/bin\/python ]] && "${python}" --version &>/dev/null
then
exec "${python}" $@
fi
done
# If we didn't find a `python`, try to use the py launcher
if command -v py &>/dev/null
then
exec py $@
fi
echo "No python command found. Please install Python"
exit 1This shell script will, in order
- Find all
pythoncommands on the${PATH} - Test each one to see if it is a valid python interpreter
- If it finds a valid python, pass all arguments to the interpreter, else
- Try to find the
pylauncher and pass all arguments to it, else - Exit with an error
I've tested it on my machine and it seems to work pretty well with a python.org Python and a Microsoft Store Python. I'm hoping with this shim, Git for Windows could start to include git-filter-repo in the same way it includes other extensions like git-flow and git-lfs, and that git-p4 could become a first-class citizen again.