engine_control/source/scripts/symlink_hooks.py

21 lines
566 B
Python

#!/usr/bin/python2
# Used to create symlink for git hooks
from sys import argv
import os
def main(argv):
pwd = os.getcwd()
base_dir = pwd.replace("source/scripts", "")
target_dir = base_dir + "config/git_hooks/"
link_dir = base_dir + ".git/hooks/"
hooks = ["post-commit", "post-merge"]
for hook in hooks:
target = target_dir + hook
link = link_dir + hook
if (os.path.islink(link)) or (os.path.isfile(link)):
os.remove(link)
os.symlink(target, link)
if __name__ == "__main__":
main(argv[1:])