Skip to content

Commit

Permalink
Fixed a lot of structural issues with the project
Browse files Browse the repository at this point in the history
  • Loading branch information
dtaivpp committed Jun 30, 2021
1 parent 3d2269d commit 1921373
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ First you will need to setup [pre-commit](https://pre-commit.com/) using their d
rev: v0.3.1
hooks:
- id: commit-msg-hook
args: [--pattern='[A-Z]{3,4}-[0-9]{3,6} \| [\w\s]* \| .+']
args: [--pattern='[A-Z]{3,4}-[0-9]{3,6} \\| [\\w\\s]* \\| .+']
stages: [commit-msg]
```

#### To enable commit-msg hook with pre-commit run:
**note the backslashes need to be escaped

### To enable commit-msg hook with pre-commit run:
`pre-commit install --hook-type commit-msg`

#### Update to the latest release (optional)
### Update to the latest release (optional)
`pre-commit autoupdate --repo https://github.com/dtaivpp/commit-msg-regex-hook.git`
6 changes: 3 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = commit-msg-regex-hook
version = v0.0.3
version = v0.0.4
author = David Tippett
description = Checks if commit message matches supplied regex
long_description = file: README.md
Expand All @@ -21,9 +21,9 @@ python_requires = >=3.6

[options.packages.find]
where = src
exclude = src.test
exclude = test


[options.entry_points]
console_scripts =
commit-msg-hook = main.cli:main
commit-msg-regex-hook = src.commit_msg_regex_hook:main
Empty file added src/__init__.py
Empty file.
File renamed without changes.
1 change: 0 additions & 1 deletion src/main/__init__.py

This file was deleted.

Empty file added test/__init__.py
Empty file.
11 changes: 5 additions & 6 deletions src/test/test.py → test/test.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
import re
import unittest
import unittest
from src.main import cli
from src import commit_msg_regex_hook


class TestMessageEmpty(unittest.TestCase):
def test_empty_message_should_fail(self):
result = cli.message_not_empty(" \n")()
result = commit_msg_regex_hook.message_not_empty(" \n")()
self.assertEqual(result.is_passing(), False)

def test_full_message_should_pass(self):
result = cli.message_not_empty("I am a whole message")()
result = commit_msg_regex_hook.message_not_empty("I am a whole message")()
self.assertEqual(result.is_passing(), True)


class TestMessagePatternMatch(unittest.TestCase):
def test_pattern_not_match(self):
pattern = re.compile(r'[A-Z]{3,4}-[0-9]{3,6} \| [\w\s]* \| .+')
test_str = "asefagrragadsrgasr"
result = cli.message_pattern_match(test_str, pattern)()
result = commit_msg_regex_hook.message_pattern_match(test_str, pattern)()
self.assertEqual(result.is_passing(), False)

def test_pattern_match(self):
pattern = re.compile(r'[A-Z]{3,4}-[0-9]{3,6} \| [\w\s]* \| .+')
test_str = "ABC-123 | David | Commit message!"
result = cli.message_pattern_match(test_str, pattern)()
result = commit_msg_regex_hook.message_pattern_match(test_str, pattern)()
self.assertEqual(result.is_passing(), True)

0 comments on commit 1921373

Please sign in to comment.