kosmos/source/scripts/symlink_hooks.py

21 lines
566 B
Python
Raw Normal View History

2016-07-28 19:02:54 +00:00
#!/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:])