Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import smmap
from jig.exc import (
NotGitRepo, PreCommitExists, JigUserDirectoryError,
GitTemplatesMissing, GitHomeTemplatesExists, GitConfigError,
InitTemplateDirAlreadySet)
from jig.conf import JIG_DIR_NAME
from jig.gitutils.scripts import RUN_JIG_SCRIPT, AUTO_JIG_INIT_SCRIPT
from jig.gitutils.checks import is_git_repo
# Dependencies to make jig run
JIG_DIR = realpath(join(dirname(__file__), '..'))
GIT_PYTHON_DIR = realpath(join(dirname(git.__file__), '..'))
GITDB_DIR = realpath(join(dirname(gitdb.__file__), '..'))
ASYNC_DIR = realpath(join(dirname(async.__file__), '..'))
SMMAP_DIR = realpath(join(dirname(smmap.__file__), '..'))
def _git_templates():
"""
Search and return the location of the shared Git templates directory.
:rtype: string or None
"""
search_locations = [
'/usr/share/git-core/templates',
'/usr/local/share/git-core/templates',
'/usr/local/git/share/git-core/templates'
]
for possible_location in search_locations:
if isdir(possible_location):
import git
from git.exc import GitCommandError
import gitdb
import async
import smmap
from jig.exc import NotGitRepo, PreCommitExists, GitCloneError
from jig.conf import JIG_DIR_NAME
# Dependencies to make jig run
BE_CAREFUL_DIR = realpath(join(dirname(__file__), '..'))
GIT_PYTHON_DIR = realpath(join(dirname(git.__file__), '..'))
GITDB_DIR = realpath(join(dirname(gitdb.__file__), '..'))
ASYNC_DIR = realpath(join(dirname(async.__file__), '..'))
SMMAP_DIR = realpath(join(dirname(smmap.__file__), '..'))
PRE_COMMIT_HOOK_SCRIPT = \
dedent("""\
#!{python_executable}
from sys import path
from os.path import dirname, join
# Make sure that we can find the directory that jig is installed
path.append('{be_careful_dir}')
path.append('{git_python_dir}')
path.append('{gitdb_dir}')
path.append('{async_dir}')
path.append('{smmap_dir}')
from jig.runner import Runner