From 6ff7af19ee77b2b9f06bdd2451ba40f230410bdb Mon Sep 17 00:00:00 2001 From: "Evan J. Felix" Date: Fri, 17 Mar 2017 13:54:34 -0700 Subject: [PATCH] cleanup some pep8 and flake issues --- pre_commit_hooks/no_commit_to_branch.py | 7 +++++-- tests/check_no_commit_to_branch_test.py | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/pre_commit_hooks/no_commit_to_branch.py b/pre_commit_hooks/no_commit_to_branch.py index 3f5e8c9..16e57b2 100644 --- a/pre_commit_hooks/no_commit_to_branch.py +++ b/pre_commit_hooks/no_commit_to_branch.py @@ -1,9 +1,10 @@ from __future__ import print_function import argparse - +import sys import util + def is_on_branch(protected): retval = False branch = util.cmd_output('git', 'symbolic-ref', 'HEAD') @@ -12,9 +13,11 @@ def is_on_branch(protected): retval = True return retval + def main(argv=None): parser = argparse.ArgumentParser() - parser.add_argument('-b', default='master', help='branch to disallow commits to') + parser.add_argument( + '-b', default='master', help='branch to disallow commits to') parser.add_argument('filenames', nargs='*', help='filenames to check.') args = parser.parse_args(argv) diff --git a/tests/check_no_commit_to_branch_test.py b/tests/check_no_commit_to_branch_test.py index 36035f7..91df387 100644 --- a/tests/check_no_commit_to_branch_test.py +++ b/tests/check_no_commit_to_branch_test.py @@ -11,14 +11,17 @@ def test_other_branch(temp_git_dir): cmd_output('git', 'checkout', '-b', 'anotherbranch') assert is_on_branch('master') is False + def test_master_branch(temp_git_dir): with temp_git_dir.as_cwd(): assert is_on_branch('master') is True + def test_main_other_call(temp_git_dir): with temp_git_dir.as_cwd(): cmd_output('git', 'checkout', '-b', 'other') - assert main(['-b','other']) == 1 + assert main(['-b', 'other']) == 1 + def test_main_default_call(temp_git_dir): with temp_git_dir.as_cwd():