Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add template for pipenv, update install routine #20

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions autohooks/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import shutil
import os

from setuptools.command.install import install
from setuptools.command.develop import develop
Expand All @@ -32,10 +33,15 @@ def get_pre_commit_hook_path():


def get_pre_commit_hook_template_path():
setup_dir_path = get_autohooks_directory_path()
return setup_dir_path / 'precommit' / 'template'
# check if in pipenv
ret_code = os.system("pipenv graph")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please always use subprocess instead of os.system



setup_dir_path = get_autohooks_directory_path() / 'precommit'
if ret_code == 0:
return setup_dir_path / 'template_pipenv'
return setup_dir_path / 'template'

def install_pre_commit_hook(pre_commit_hook_file, pre_commit_hook):
shutil.copy(str(pre_commit_hook_file), str(pre_commit_hook))

Expand Down
11 changes: 11 additions & 0 deletions autohooks/precommit/template_pipenv
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env pipenv run python3

import sys

try:
from autohooks.precommit import run
sys.exit(run())
except ImportError:
print('autohooks not installed. Ignoring pre-commit hook.')
sys.exit(0)