Skip to content

Commit

Permalink
Clean up, fixes in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
barseghyanartur committed Nov 22, 2019
1 parent 1f44a9d commit d245ef7
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 33 deletions.
16 changes: 13 additions & 3 deletions src/matyan/auto_correct.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,31 @@
__all__ = (
'add_final_dot',
'capitalize',
'capitalize_first_letter',
'unslugify',
)


def capitalize_first_letter(value: AnyStr) -> AnyStr:
if len(value) == 0:
return value
return value[0].upper() + value[1:]


def unslugify(value: AnyStr) -> AnyStr:
return value.replace('-', ' ').title() if value else ''
return capitalize_first_letter(value.replace('-', ' ')) if value else ''


def capitalize(value: AnyStr) -> AnyStr:
return value
if len(value) == 0:
return value
return '. '.join([val.strip().capitalize() for val in value.split('.')]).strip()
return '. '.join(
[capitalize_first_letter(val.strip()) for val in value.split('.')]
).strip()


def add_final_dot(value: AnyStr) -> AnyStr:
if len(value) and value[-1].isalnum():
if len(value) and value[-1].isalnum() and not value.endswith('.'):
return value + "."
return value
10 changes: 5 additions & 5 deletions src/matyan/tests/output/generate-changelog-headings-only.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
**Feature**

*MSFT-1238 Token Authentication*
*MSFT-1238 Token authentication*

*MSFT-1237 Improve Document Sharing*
*MSFT-1237 Improve document sharing*

*MSFT-1234 Car Type Suggester*
*MSFT-1234 Car type suggester*

**Bugfix**

*MSFT-1236 Prevent Duplicate Postal Codes*
*MSFT-1236 Prevent duplicate postal codes*

**Deprecation**

*MSFT-1235 Deprecate Old Api*
*MSFT-1235 Deprecate old api*
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

**Feature**

*MSFT-1238 Token Authentication*
*MSFT-1238 Token authentication*

- Update authentication docs. [Artur Barseghyan]
- Implement token authentication. [Artur Barseghyan]

*MSFT-1237 Improve Document Sharing*
*MSFT-1237 Improve document sharing*

- Improve document sharing. Add option to share via GDrive. [Artur Barseghyan]
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

**Feature**

*MSFT-1238 Token Authentication*
*MSFT-1238 Token authentication*

*MSFT-1237 Improve Document Sharing*
*MSFT-1237 Improve document sharing*

### 0.1

**Bugfix**

*MSFT-1236 Prevent Duplicate Postal Codes*
*MSFT-1236 Prevent duplicate postal codes*

**Deprecation**

*MSFT-1235 Deprecate Old Api*
*MSFT-1235 Deprecate old api*

**Feature**

*MSFT-1234 Car Type Suggester*
*MSFT-1234 Car type suggester*
10 changes: 5 additions & 5 deletions src/matyan/tests/output/generate-changelog-show-releases.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,35 @@

**Feature**

*MSFT-1238 Token Authentication*
*MSFT-1238 Token authentication*

- Update authentication docs. [Artur Barseghyan]
- Implement token authentication. [Artur Barseghyan]

*MSFT-1237 Improve Document Sharing*
*MSFT-1237 Improve document sharing*

- Improve document sharing. Add option to share via GDrive. [Artur Barseghyan]

### 0.1

**Bugfix**

*MSFT-1236 Prevent Duplicate Postal Codes*
*MSFT-1236 Prevent duplicate postal codes*

- Make postal code field unique for the country. [Artur Barseghyan]
- Normalise postal codes for US addresses. [Artur Barseghyan]
- Normalise postal codes for German addresses. [Artur Barseghyan]

**Deprecation**

*MSFT-1235 Deprecate Old Api*
*MSFT-1235 Deprecate old api*

- Update docs. [Artur Barseghyan]
- Deprecate API v 2.0. [Artur Barseghyan]

**Feature**

*MSFT-1234 Car Type Suggester*
*MSFT-1234 Car type suggester*

- Add insurance amount indication based on car weight. [Artur Barseghyan]
- Initial car type suggester implementation. [Artur Barseghyan]
10 changes: 5 additions & 5 deletions src/matyan/tests/output/generate-changelog.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
**Feature**

*MSFT-1238 Token Authentication*
*MSFT-1238 Token authentication*

- Update authentication docs. [Artur Barseghyan]
- Implement token authentication. [Artur Barseghyan]

*MSFT-1237 Improve Document Sharing*
*MSFT-1237 Improve document sharing*

- Improve document sharing. Add option to share via GDrive. [Artur Barseghyan]

*MSFT-1234 Car Type Suggester*
*MSFT-1234 Car type suggester*

- Add insurance amount indication based on car weight. [Artur Barseghyan]
- Initial car type suggester implementation. [Artur Barseghyan]

**Bugfix**

*MSFT-1236 Prevent Duplicate Postal Codes*
*MSFT-1236 Prevent duplicate postal codes*

- Make postal code field unique for the country. [Artur Barseghyan]
- Normalise postal codes for US addresses. [Artur Barseghyan]
- Normalise postal codes for German addresses. [Artur Barseghyan]

**Deprecation**

*MSFT-1235 Deprecate Old Api*
*MSFT-1235 Deprecate old api*

- Update docs. [Artur Barseghyan]
- Deprecate API v 2.0. [Artur Barseghyan]
2 changes: 1 addition & 1 deletion src/matyan/tests/output/json-changelog-headings-only.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{'feature': {'MSFT-1238': {'commit_hash': 'c42ff7ed2e5b1a3c42ead2b81735397cefc554b8', 'commit_abbr': 'c42ff7e', 'date': '2019-11-17 20:50:49 +0000', 'ticket_number': 'MSFT-1238', 'branch_type': 'feature', 'slug': 'Token-authentication', 'title': 'Token Authentication', 'commits': {}, 'release': '0.2'}, 'MSFT-1237': {'commit_hash': '2d799b037160961d7ebc6e552dfd63c60b155553', 'commit_abbr': '2d799b0', 'date': '2019-11-17 20:48:51 +0000', 'ticket_number': 'MSFT-1237', 'branch_type': 'feature', 'slug': 'Improve-document-sharing', 'title': 'Improve Document Sharing', 'commits': {}, 'release': '0.2'}, 'MSFT-1234': {'commit_hash': '5babfbe19a31a8386f52d730eccd4df60fb775dd', 'commit_abbr': '5babfbe', 'date': '2019-11-17 20:40:43 +0000', 'ticket_number': 'MSFT-1234', 'branch_type': 'feature', 'slug': 'car-type-suggester', 'title': 'Car Type Suggester', 'commits': {}, 'release': '0.1'}}, 'bugfix': {'MSFT-1236': {'commit_hash': '5d20c1b24c0dce57b8972250d09d417e41b6faf2', 'commit_abbr': '5d20c1b', 'date': '2019-11-17 20:46:22 +0000', 'ticket_number': 'MSFT-1236', 'branch_type': 'bugfix', 'slug': 'prevent-duplicate-postal-codes', 'title': 'Prevent Duplicate Postal Codes', 'commits': {}, 'release': '0.1'}}, 'deprecation': {'MSFT-1235': {'commit_hash': 'd794c5aa297d3bf34fe20cb47b3e04a298915357', 'commit_abbr': 'd794c5a', 'date': '2019-11-17 20:42:47 +0000', 'ticket_number': 'MSFT-1235', 'branch_type': 'deprecation', 'slug': 'deprecate-old-api', 'title': 'Deprecate Old Api', 'commits': {}, 'release': '0.1'}}}
{'feature': {'MSFT-1238': {'commit_hash': 'c42ff7ed2e5b1a3c42ead2b81735397cefc554b8', 'commit_abbr': 'c42ff7e', 'date': '2019-11-17 20:50:49 +0000', 'ticket_number': 'MSFT-1238', 'branch_type': 'feature', 'slug': 'Token-authentication', 'title': 'Token authentication', 'commits': {}, 'release': '0.2'}, 'MSFT-1237': {'commit_hash': '2d799b037160961d7ebc6e552dfd63c60b155553', 'commit_abbr': '2d799b0', 'date': '2019-11-17 20:48:51 +0000', 'ticket_number': 'MSFT-1237', 'branch_type': 'feature', 'slug': 'Improve-document-sharing', 'title': 'Improve document sharing', 'commits': {}, 'release': '0.2'}, 'MSFT-1234': {'commit_hash': '5babfbe19a31a8386f52d730eccd4df60fb775dd', 'commit_abbr': '5babfbe', 'date': '2019-11-17 20:40:43 +0000', 'ticket_number': 'MSFT-1234', 'branch_type': 'feature', 'slug': 'car-type-suggester', 'title': 'Car type suggester', 'commits': {}, 'release': '0.1'}}, 'bugfix': {'MSFT-1236': {'commit_hash': '5d20c1b24c0dce57b8972250d09d417e41b6faf2', 'commit_abbr': '5d20c1b', 'date': '2019-11-17 20:46:22 +0000', 'ticket_number': 'MSFT-1236', 'branch_type': 'bugfix', 'slug': 'prevent-duplicate-postal-codes', 'title': 'Prevent duplicate postal codes', 'commits': {}, 'release': '0.1'}}, 'deprecation': {'MSFT-1235': {'commit_hash': 'd794c5aa297d3bf34fe20cb47b3e04a298915357', 'commit_abbr': 'd794c5a', 'date': '2019-11-17 20:42:47 +0000', 'ticket_number': 'MSFT-1235', 'branch_type': 'deprecation', 'slug': 'deprecate-old-api', 'title': 'Deprecate old api', 'commits': {}, 'release': '0.1'}}}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{'0.2': {'feature': {'MSFT-1238': {'commit_hash': 'c42ff7ed2e5b1a3c42ead2b81735397cefc554b8', 'commit_abbr': 'c42ff7e', 'date': '2019-11-17 20:50:49 +0000', 'ticket_number': 'MSFT-1238', 'branch_type': 'feature', 'slug': 'Token-authentication', 'title': 'Token Authentication', 'commits': {'Update authentication docs': {'commit_hash': '513e790ccf0a7f3024fb226b0c530e04528ff046', 'commit_abbr': '513e790', 'author': 'Artur Barseghyan', 'date': '2019-11-17 21:50:08 +0100', 'ticket_number': 'MSFT-1238', 'title': 'Update authentication docs'}, 'Implement token authentication': {'commit_hash': '7fbd3035ef40d0f311469ec88088266bc7d13f5c', 'commit_abbr': '7fbd303', 'author': 'Artur Barseghyan', 'date': '2019-11-17 21:49:49 +0100', 'ticket_number': 'MSFT-1238', 'title': 'Implement token authentication'}}, 'release': '0.2'}, 'MSFT-1237': {'commit_hash': '2d799b037160961d7ebc6e552dfd63c60b155553', 'commit_abbr': '2d799b0', 'date': '2019-11-17 20:48:51 +0000', 'ticket_number': 'MSFT-1237', 'branch_type': 'feature', 'slug': 'Improve-document-sharing', 'title': 'Improve Document Sharing', 'commits': {'Improve document sharing. Add option to share via GDrive': {'commit_hash': 'b54d3263c3d14cc77e73e730228ac064551145cc', 'commit_abbr': 'b54d326', 'author': 'Artur Barseghyan', 'date': '2019-11-17 21:48:04 +0100', 'ticket_number': 'MSFT-1237', 'title': 'Improve document sharing. Add option to share via GDrive'}}, 'release': '0.2'}}}}
{'0.2': {'feature': {'MSFT-1238': {'commit_hash': 'c42ff7ed2e5b1a3c42ead2b81735397cefc554b8', 'commit_abbr': 'c42ff7e', 'date': '2019-11-17 20:50:49 +0000', 'ticket_number': 'MSFT-1238', 'branch_type': 'feature', 'slug': 'Token-authentication', 'title': 'Token authentication', 'commits': {'Update authentication docs.': {'commit_hash': '513e790ccf0a7f3024fb226b0c530e04528ff046', 'commit_abbr': '513e790', 'author': 'Artur Barseghyan', 'date': '2019-11-17 21:50:08 +0100', 'ticket_number': 'MSFT-1238', 'title': 'Update authentication docs.'}, 'Implement token authentication.': {'commit_hash': '7fbd3035ef40d0f311469ec88088266bc7d13f5c', 'commit_abbr': '7fbd303', 'author': 'Artur Barseghyan', 'date': '2019-11-17 21:49:49 +0100', 'ticket_number': 'MSFT-1238', 'title': 'Implement token authentication.'}}, 'release': '0.2'}, 'MSFT-1237': {'commit_hash': '2d799b037160961d7ebc6e552dfd63c60b155553', 'commit_abbr': '2d799b0', 'date': '2019-11-17 20:48:51 +0000', 'ticket_number': 'MSFT-1237', 'branch_type': 'feature', 'slug': 'Improve-document-sharing', 'title': 'Improve document sharing', 'commits': {'Improve document sharing. Add option to share via GDrive.': {'commit_hash': 'b54d3263c3d14cc77e73e730228ac064551145cc', 'commit_abbr': 'b54d326', 'author': 'Artur Barseghyan', 'date': '2019-11-17 21:48:04 +0100', 'ticket_number': 'MSFT-1237', 'title': 'Improve document sharing. Add option to share via GDrive.'}}, 'release': '0.2'}}}}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{'0.2': {'feature': {'MSFT-1238': {'commit_hash': 'c42ff7ed2e5b1a3c42ead2b81735397cefc554b8', 'commit_abbr': 'c42ff7e', 'date': '2019-11-17 20:50:49 +0000', 'ticket_number': 'MSFT-1238', 'branch_type': 'feature', 'slug': 'Token-authentication', 'title': 'Token Authentication', 'commits': {}, 'release': '0.2'}, 'MSFT-1237': {'commit_hash': '2d799b037160961d7ebc6e552dfd63c60b155553', 'commit_abbr': '2d799b0', 'date': '2019-11-17 20:48:51 +0000', 'ticket_number': 'MSFT-1237', 'branch_type': 'feature', 'slug': 'Improve-document-sharing', 'title': 'Improve Document Sharing', 'commits': {}, 'release': '0.2'}}}, '0.1': {'bugfix': {'MSFT-1236': {'commit_hash': '5d20c1b24c0dce57b8972250d09d417e41b6faf2', 'commit_abbr': '5d20c1b', 'date': '2019-11-17 20:46:22 +0000', 'ticket_number': 'MSFT-1236', 'branch_type': 'bugfix', 'slug': 'prevent-duplicate-postal-codes', 'title': 'Prevent Duplicate Postal Codes', 'commits': {}, 'release': '0.1'}}, 'deprecation': {'MSFT-1235': {'commit_hash': 'd794c5aa297d3bf34fe20cb47b3e04a298915357', 'commit_abbr': 'd794c5a', 'date': '2019-11-17 20:42:47 +0000', 'ticket_number': 'MSFT-1235', 'branch_type': 'deprecation', 'slug': 'deprecate-old-api', 'title': 'Deprecate Old Api', 'commits': {}, 'release': '0.1'}}, 'feature': {'MSFT-1234': {'commit_hash': '5babfbe19a31a8386f52d730eccd4df60fb775dd', 'commit_abbr': '5babfbe', 'date': '2019-11-17 20:40:43 +0000', 'ticket_number': 'MSFT-1234', 'branch_type': 'feature', 'slug': 'car-type-suggester', 'title': 'Car Type Suggester', 'commits': {}, 'release': '0.1'}}}}
{'0.2': {'feature': {'MSFT-1238': {'commit_hash': 'c42ff7ed2e5b1a3c42ead2b81735397cefc554b8', 'commit_abbr': 'c42ff7e', 'date': '2019-11-17 20:50:49 +0000', 'ticket_number': 'MSFT-1238', 'branch_type': 'feature', 'slug': 'Token-authentication', 'title': 'Token authentication', 'commits': {}, 'release': '0.2'}, 'MSFT-1237': {'commit_hash': '2d799b037160961d7ebc6e552dfd63c60b155553', 'commit_abbr': '2d799b0', 'date': '2019-11-17 20:48:51 +0000', 'ticket_number': 'MSFT-1237', 'branch_type': 'feature', 'slug': 'Improve-document-sharing', 'title': 'Improve document sharing', 'commits': {}, 'release': '0.2'}}}, '0.1': {'bugfix': {'MSFT-1236': {'commit_hash': '5d20c1b24c0dce57b8972250d09d417e41b6faf2', 'commit_abbr': '5d20c1b', 'date': '2019-11-17 20:46:22 +0000', 'ticket_number': 'MSFT-1236', 'branch_type': 'bugfix', 'slug': 'prevent-duplicate-postal-codes', 'title': 'Prevent duplicate postal codes', 'commits': {}, 'release': '0.1'}}, 'deprecation': {'MSFT-1235': {'commit_hash': 'd794c5aa297d3bf34fe20cb47b3e04a298915357', 'commit_abbr': 'd794c5a', 'date': '2019-11-17 20:42:47 +0000', 'ticket_number': 'MSFT-1235', 'branch_type': 'deprecation', 'slug': 'deprecate-old-api', 'title': 'Deprecate old api', 'commits': {}, 'release': '0.1'}}, 'feature': {'MSFT-1234': {'commit_hash': '5babfbe19a31a8386f52d730eccd4df60fb775dd', 'commit_abbr': '5babfbe', 'date': '2019-11-17 20:40:43 +0000', 'ticket_number': 'MSFT-1234', 'branch_type': 'feature', 'slug': 'car-type-suggester', 'title': 'Car type suggester', 'commits': {}, 'release': '0.1'}}}}

0 comments on commit d245ef7

Please sign in to comment.