Say I want to delete 'Core.dll' after 'git pull', so I write a hook.
import os
dir = os.path.dirname(__file__)
try:
os.remove(os.path.abspath(dir+os.sep+".."+os.sep+".."+os.sep+"Assets"+os.sep+"Plugins"+os.sep+"Core.dll"))
except OSError:
pass
Say the hook path is 'E:\client\.git\hooks', the file I want to delete is in 'E:\client\Assets\Plugins\Core.dll'.
I think my way is very silly, is there any elegant way to get the relative path?
os.path.joinand os.pardir would be better/will work as a directory separator on all platforms where you'd use both git and python... But also, on Python 3, seepathlib. If on Python 2 -> switch to Python 3.dir.