diff --git a/.gitignore b/.gitignore index b81586fe..33211632 100644 --- a/.gitignore +++ b/.gitignore @@ -470,6 +470,9 @@ cscope.in.out cscope.po.out +docs/level-1-jinja2-cli/testout +docs/level-10-moban-dependency-as-git-repo/mytravis.yml +docs/level-18-user-defined-template-types/b.output docs/level-9-moban-dependency-as-pypi-package/mytravis.yml docs/misc-1-copying-templates/misc-1-copying/ docs/misc-1-copying-templates/test-dir/ diff --git a/.moban.cd/changelog.yml b/.moban.cd/changelog.yml index 7a3af283..d3d62028 100644 --- a/.moban.cd/changelog.yml +++ b/.moban.cd/changelog.yml @@ -5,7 +5,8 @@ releases: - action: Added details: - "`#234`: Define template parameters on the fly inside `targets` section" - date: 01.03.2019 + - "`#180`: No longer two statistics will be shown in v0.4.x. legacy copy targets are injected into a normal targets. cli target is made a clear priority." + date: unreleased version: 0.4.2 - changes: - action: Added diff --git a/.moban.d/moban_gitignore.jj2 b/.moban.d/moban_gitignore.jj2 index ac301d54..856dc75a 100644 --- a/.moban.d/moban_gitignore.jj2 +++ b/.moban.d/moban_gitignore.jj2 @@ -1,6 +1,9 @@ {% extends "gitignore.jj2" %} {% block extra %} +docs/level-1-jinja2-cli/testout +docs/level-10-moban-dependency-as-git-repo/mytravis.yml +docs/level-18-user-defined-template-types/b.output docs/level-9-moban-dependency-as-pypi-package/mytravis.yml docs/misc-1-copying-templates/misc-1-copying/ docs/misc-1-copying-templates/test-dir/ diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 272797f1..bda431c3 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,7 +1,7 @@ Change log ================================================================================ -0.4.2 - 01.03.2019 +0.4.2 - unreleased -------------------------------------------------------------------------------- Added @@ -9,6 +9,9 @@ Added #. `#234 `_: Define template parameters on the fly inside `targets` section +#. `#180 `_: No longer two + statistics will be shown in v0.4.x. legacy copy targets are injected into a + normal targets. cli target is made a clear priority. 0.4.1 - 28.02.2019 -------------------------------------------------------------------------------- diff --git a/moban/mobanfile/__init__.py b/moban/mobanfile/__init__.py index 455b30f2..5086f8ea 100644 --- a/moban/mobanfile/__init__.py +++ b/moban/mobanfile/__init__.py @@ -36,8 +36,14 @@ def find_default_moban_file(): def handle_moban_file_v1(moban_file_configurations, command_line_options): merged_options = None - targets = moban_file_configurations.get(constants.LABEL_TARGETS) - target = extract_target(command_line_options) + targets = moban_file_configurations.get(constants.LABEL_TARGETS, []) + if constants.LABEL_COPY in moban_file_configurations: + legacy_copy_targets = handle_copy( + merged_options, moban_file_configurations[constants.LABEL_COPY] + ) + targets += legacy_copy_targets + + cli_target = extract_target(command_line_options) if constants.LABEL_CONFIG in moban_file_configurations: merged_options = merge( @@ -68,27 +74,16 @@ def handle_moban_file_v1(moban_file_configurations, command_line_options): if template_types: plugins.ENGINES.register_options(template_types) - if targets: - if target: - targets = target - # If template specified via CLI flag `-t: - # 1. Only update the specified template - # 2. Do not copy - if constants.LABEL_COPY in moban_file_configurations: - del moban_file_configurations[constants.LABEL_COPY] - number_of_templated_files = handle_targets(merged_options, targets) + if cli_target: + number_of_templated_files = handle_targets( + merged_options, [cli_target]) + elif targets: + number_of_templated_files = handle_targets( + merged_options, targets) else: number_of_templated_files = 0 - if constants.LABEL_COPY in moban_file_configurations: - number_of_copied_files = handle_copy( - merged_options, moban_file_configurations[constants.LABEL_COPY] - ) - else: - number_of_copied_files = 0 - exit_code = reporter.convert_to_shell_exit_code( - number_of_templated_files + number_of_copied_files - ) + exit_code = reporter.convert_to_shell_exit_code(number_of_templated_files) reporter.report_up_to_date() return exit_code @@ -100,12 +95,11 @@ def handle_copy(merged_options, copy_config): copy_targets.append( { constants.LABEL_TEMPLATE: src, - constants.LABEL_CONFIG: None, constants.LABEL_OUTPUT: dest, constants.LABEL_TEMPLATE_TYPE: constants.TEMPLATE_COPY, } ) - return handle_targets(merged_options, copy_targets) + return copy_targets def _iterate_list_of_dicts(list_of_dict): @@ -134,6 +128,7 @@ def handle_targets(merged_options, targets): target.set_template_type(primary_template_type) jobs_for_each_engine[primary_template_type].append(target) + print(target) count = 0 for template_type in jobs_for_each_engine.keys(): @@ -172,15 +167,14 @@ def extract_target(options): "Please specify a output file name for %s." % template ) if config: - result = [ - { + result = { constants.LABEL_TEMPLATE: template, constants.LABEL_CONFIG: config, constants.LABEL_OUTPUT: output, } - ] + else: - result = [{output: template}] + result = {output: template} return result