diff --git a/balkian_pre_commit/branchversion.py b/balkian_pre_commit/branchversion.py index 48c1a5a..5380050 100644 --- a/balkian_pre_commit/branchversion.py +++ b/balkian_pre_commit/branchversion.py @@ -8,17 +8,19 @@ def main(argv=None): parser.add_argument('filenames', nargs='*') args = parser.parse_args(argv) branch_name = check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']).strip().decode() + error = 1 for fn in args.filenames: - if os.path.basename(fn) == 'VERSION': - with open(fn) as f: - currentcontent = f.read().strip() - prevcontent = check_output(['git', 'show', 'HEAD:{}'.format(fn)]).strip().decode() - current = semver.parse_version_info(currentcontent) - print('Checking versions: {} -> {}'.format(prevcontent, currentcontent)) - if (branch_name == 'master' and current.prerelease) or\ - (semver.compare(currentcontent, prevcontent)<1): - return 1 - return 0 + with open(fn) as f: + currentcontent = f.read().strip() + prevcontent = check_output(['git', 'show', 'HEAD:{}'.format(fn)]).strip().decode() + current = semver.parse_version_info(currentcontent) + print('Checking versions: {} -> {}'.format(prevcontent, currentcontent)) + if (branch_name == 'master' and current.prerelease) or\ + (semver.compare(currentcontent, prevcontent)<1): + return 1 + else: + error = 0 + return error if __name__ == '__main__': exit(main()) diff --git a/hooks.yaml b/hooks.yaml index 031f13f..9eb7d83 100644 --- a/hooks.yaml +++ b/hooks.yaml @@ -3,4 +3,5 @@ description: This hook avoids commiting a pre-release to a master branch. entry: branchversion language: python + always_run: True files: "VERSION$"