-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #96 from jedie/dev
Autogenerate history via https://github.com/jedie/cli-base-utilities
- Loading branch information
Showing
7 changed files
with
553 additions
and
382 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from unittest import TestCase | ||
|
||
from bx_py_utils.auto_doc import assert_readme_block | ||
from cli_base.cli_tools.git_history import get_git_history | ||
|
||
import manageprojects | ||
from manageprojects.cli.dev import PACKAGE_ROOT | ||
|
||
|
||
class ReadmeHistoryTestCase(TestCase): | ||
def test_readme_history(self): | ||
git_history = get_git_history( | ||
current_version=manageprojects.__version__, | ||
add_author=False, | ||
) | ||
history = '\n'.join(git_history) | ||
assert_readme_block( | ||
readme_path=PACKAGE_ROOT / 'README.md', | ||
text_block=f'\n{history}\n', | ||
start_marker_line='[comment]: <> (✂✂✂ auto generated history start ✂✂✂)', | ||
end_marker_line='[comment]: <> (✂✂✂ auto generated history end ✂✂✂)', | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
import logging | ||
|
||
from cookiecutter.generate import generate_files | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class CookieCutterHookHandler: | ||
class GenerateFilesWrapper: | ||
""" | ||
Capture the effective Cookiecutter Template Context via injecting the Cookiecutter hooks. | ||
Capture the effective Cookiecutter Template Context | ||
""" | ||
|
||
def __init__(self, origin_run_hook): | ||
self.origin_run_hook = origin_run_hook | ||
self.context = {} | ||
def __init__(self): | ||
self.context = None | ||
|
||
def __call__(self, hook_name, project_dir, context): | ||
logger.debug('Hook %r for %r context: %r', hook_name, project_dir, context) | ||
origin_hook_result = self.origin_run_hook(hook_name, project_dir, context) | ||
self.context.update(context) | ||
return origin_hook_result | ||
def __call__(self, **kwargs): | ||
logger.debug('GenerateFilesWrapper called with: %s', kwargs) | ||
self.context = kwargs['context'] | ||
return generate_files(**kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.