Skip to content

Commit

Permalink
Prepare 0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
barseghyanartur committed Nov 19, 2019
1 parent 7b3ce70 commit f273729
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 70 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ are used for versioning (schema follows below):
0.3.4 to 0.4).
- All backwards incompatible changes are mentioned in this document.

0.3
---
2019-11-20

- Most of the functions got optional ``path`` parameter to use as
path to the repository directory.
- ``matyan-create-config`` command renamed to ``matyan-make-config``.
- Next to the commands, functions are tested as well.
- Fix issue with lower edge nog being included when using dotted range.

0.2.1
-----
2019-11-19
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
except:
readme = ''

version = '0.2.1'
version = '0.3'

setup(
name='matyan',
Expand Down Expand Up @@ -40,7 +40,7 @@
'json-changelog = matyan.utils:json_changelog_cli',
'generate-changelog = matyan.utils:generate_changelog_cli',
# Specific
'matyan-create-config = matyan.utils:create_config_file_cli',
'matyan-make-config = matyan.utils:make_config_file_cli',
# Backups
'matyan-json-changelog = matyan.utils:json_changelog_cli',
'matyan-generate-changelog = matyan.utils:generate_changelog_cli',
Expand Down
12 changes: 7 additions & 5 deletions src/matyan/__init__.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
from .utils import (
prepare_changelog,
json_changelog_cli,
generate_changelog,
generate_changelog_cli,
json_changelog_cli,
prepare_changelog,
)

__title__ = 'matyan'
__version__ = '0.2.1'
__version__ = '0.3'
__author__ = 'Artur Barseghyan'
__copyright__ = '2019 Artur Barseghyan'
__license__ = 'GPL-2.0-only OR LGPL-2.0-or-later'
__all__ = (
'prepare_changelog',
'json_changelog_cli',
'generate_changelog',
'generate_changelog_cli',
'json_changelog_cli',
'prepare_changelog',
)
10 changes: 10 additions & 0 deletions src/matyan/tests/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,13 @@ def prepare_changelog_data(cls):
)
with open(changelog_releases_output, 'r') as file:
cls.changelog_releases_output = file.read().strip()

# Expected output of the
# `generate-changelog --show-releases --latest-release`
# command.
changelog_latest_release_show_releases_output = project_dir(
'tests/output/generate-changelog-latest-release-show-releases.md'
)
with open(changelog_latest_release_show_releases_output, 'r') as file:
cls.changelog_latest_release_show_releases_output \
= file.read().strip()
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
### 0.2

**Feature**

*MSFT-1238 Token Authentication*

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

*MSFT-1237 Improve Document Sharing*

- Improve document sharing. Add option to share via GDrive [Artur Barseghyan]
32 changes: 18 additions & 14 deletions src/matyan/tests/test_commands.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
import os
import logging
import unittest

import subprocess
import git

from ..helpers import project_dir
from .base import (
log_info,
internet_available_only,
is_internet_available,
internet_available_or_is_travis_only,
is_travis,
)

from .base import log_info
from .mixins import ChangelogMixin

__author__ = 'Artur Barseghyan'
Expand All @@ -24,7 +15,7 @@


class TestCommands(unittest.TestCase, ChangelogMixin):
"""Matyan commands tests."""
"""Commands tests."""

maxDiff = None

Expand All @@ -34,7 +25,6 @@ def setUpClass(cls):
super(TestCommands, cls).setUpClass()
cls.prepare_changelog_data()

# @internet_available_or_is_travis_only
@log_info
def test_01_generate_changelog_command(self):
"""Test generate changelog command."""
Expand All @@ -45,7 +35,6 @@ def test_01_generate_changelog_command(self):
self.assertEqual(res, self.changelog_output)
return res

# @internet_available_or_is_travis_only
@log_info
def test_02_generate_changelog_command_show_releases(self):
"""Test generate changelog command."""
Expand All @@ -57,6 +46,21 @@ def test_02_generate_changelog_command_show_releases(self):
self.assertEqual(res, self.changelog_releases_output)
return res

@log_info
def test_03_generate_changelog_command_show_latest_release(self):
"""Test generate changelog command."""
res = subprocess.check_output([
'generate-changelog',
'--show-releases',
'--latest-release',
'--no-other'
]).strip().decode()
self.assertEqual(
res,
self.changelog_latest_release_show_releases_output
)
return res


if __name__ == '__main__':
unittest.main()
31 changes: 18 additions & 13 deletions src/matyan/tests/test_core.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
# -*- coding: utf-8 -*-

import copy
import re
import logging
import os
import unittest
from unittest import mock

from ..utils import (
create_config_file,
make_config_file,
generate_changelog,
generate_empty_tree,
get_branch_type,
get_logs,
json_changelog,
Expand All @@ -22,11 +16,7 @@
REGEX_PATTERN_MERGED_BRANCH_NAME,
)

from .base import (
internet_available_only,
log_info,
internet_available_or_is_travis_only,
)
from .base import log_info
from .mixins import ChangelogMixin

__author__ = 'Artur Barseghyan'
Expand Down Expand Up @@ -69,7 +59,22 @@ def test_02_generate_changelog_show_releases(self):
return res

@log_info
def test_03_merge_branch_patterns(self):
def test_03_generate_changelog_latest_release_show_releases(self):
"""Test generate changelog."""
res = generate_changelog(
include_other=False,
show_releases=True,
latest_release=True,
path=self.test_dir
).strip()
self.assertEqual(
res,
self.changelog_latest_release_show_releases_output
)
return res

@log_info
def test_04_merge_branch_patterns(self):
"""Test generate changelog."""
merge_messages = {
'Merge pull request #1234 in PROJ/repo from bugfix/PROJ-'
Expand Down
74 changes: 38 additions & 36 deletions src/matyan/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@
__copyright__ = '2019 Artur Barseghyan'
__license__ = 'GPL-2.0-only OR LGPL-2.0-or-later'
__all__ = (
'create_config_file',
'generate_changelog',
'generate_changelog_cli',
'generate_empty_tree',
'get_branch_type',
'get_logs',
'json_changelog',
'json_changelog_cli',
'make_config_file',
'make_config_file_cli',
'prepare_changelog',
'prepare_releases_changelog',
'generate_changelog',
'json_changelog',
'validate_between',
)

Expand Down Expand Up @@ -103,8 +103,9 @@ def get_logs(between: str = None, path: str = None) -> Dict[str, Any]:
# Merges log
text_log_merges_args = []
if lower and upper:
# Note, that ~1 addition make sure the lower range is inclusive
text_log_merges_args.append(
"{}..{}".format(lower, upper)
"{}~1..{}".format(lower, upper)
)
text_log_merges_args.extend([
"--pretty={}".format(PRETTY_FORMAT),
Expand All @@ -118,8 +119,9 @@ def get_logs(between: str = None, path: str = None) -> Dict[str, Any]:
# Commits log
text_log_args = []
if lower and upper:
# Note, that ~1 addition make sure the lower range is inclusive
text_log_args.append(
"{}..{}".format(lower, upper)
"{}~1..{}".format(lower, upper)
)
text_log_args.extend([
"--pretty={}".format(PRETTY_FORMAT),
Expand Down Expand Up @@ -166,32 +168,32 @@ def get_branch_type(branch_type: AnyStr) -> str:
return branch_type if branch_type in BRANCH_TYPES else BRANCH_TYPE_OTHER


def generate_empty_tree() -> Dict[str, dict]:
"""Generate empty tree.
Example:
{
'feature': {},
'bugfix': {},
'hotfix': {},
'deprecation': {},
'other': {
TICKET_NUMBER_OTHER: {
# 'title': '',
'commits': {}
}
},
}
:return:
"""
empty_tree = {}
for key, value in BRANCH_TYPES.items():
empty_tree.update({key: {}})

empty_tree[BRANCH_TYPE_OTHER][TICKET_NUMBER_OTHER] = {'commits': {}}
return empty_tree
# def generate_empty_tree() -> Dict[str, dict]:
# """Generate empty tree.
#
# Example:
#
# {
# 'feature': {},
# 'bugfix': {},
# 'hotfix': {},
# 'deprecation': {},
# 'other': {
# TICKET_NUMBER_OTHER: {
# # 'title': '',
# 'commits': {}
# }
# },
# }
#
# :return:
# """
# empty_tree = {}
# for key, value in BRANCH_TYPES.items():
# empty_tree.update({key: {}})
#
# empty_tree[BRANCH_TYPE_OTHER][TICKET_NUMBER_OTHER] = {'commits': {}}
# return empty_tree


def prepare_changelog(
Expand Down Expand Up @@ -846,8 +848,8 @@ def generate_changelog_cli() -> Type[None]:
)


def create_config_file() -> bool:
"""Create (or overwrite) config file.
def make_config_file() -> bool:
"""Make (or overwrite) config file.
:return:
"""
Expand All @@ -860,5 +862,5 @@ def create_config_file() -> bool:
return False


def create_config_file_cli():
return not create_config_file()
def make_config_file_cli():
return not make_config_file()

0 comments on commit f273729

Please sign in to comment.