def test_config_handles_empty_file(config_factory): config_factory() assert Config().read() == { "release": False, "allow_dirty": False, "commit": False }
def test_config_picks_up_list_values(config_factory, branches): config_factory(""" [changelog_gen] {} """.format(branches)) c = Config().read() assert c["allowed_branches"] == ["master", "feature/11"]
def test_config_picks_up_boolean_values(config_factory, release): config_factory(""" [changelog_gen] {} """.format(release)) c = Config().read() assert c["release"] is True
def test_config_picks_up_strings_values(config_factory, issue_link): config_factory(""" [changelog_gen] {} """.format(issue_link)) c = Config().read() assert c[ "issue_link"] == "https://github.com/EdgyEdgemond/changelog-gen/issues/{}"
def test_config_picks_up_custom_sections(config_factory): config_factory(""" [changelog_gen] sections = bug=Bugfixes feat=New Features remove=Removals """) c = Config().read() assert c["sections"] == { "bug": "Bugfixes", "feat": "New Features", "remove": "Removals" }
def test_config_picks_up_section_mapping(config_factory): config_factory(""" [changelog_gen] section_mapping = feature=feat bug=fix test=fix """) c = Config().read() assert c["section_mapping"] == { "feature": "feat", "bug": "fix", "test": "fix" }
def test_config_handles_missing_file(cwd): assert Config().read() == {}
def _gen(dry_run=False, allow_dirty=False, release=False, commit=False, version_tag=None): config = Config().read() release = config.get("release") or release allow_dirty = config.get("allow_dirty") or allow_dirty commit = config.get("commit") or commit extension = util.detect_extension() if extension is None: click.echo("No CHANGELOG file detected, run changelog-init") raise click.Abort() process_info(Git.get_latest_tag_info(), dry_run, allow_dirty, config) # TODO: supported default extensions (steal from conventional commits) # TODO: support multiple extras by default (the usuals) section_mapping = config.get("section_mapping", {}) supported_sections = config.get("sections", SUPPORTED_SECTIONS) e = extractor.ReleaseNoteExtractor(dry_run=dry_run, supported_sections=supported_sections) sections = e.extract(section_mapping) semver = None if version_tag is None: semver = "minor" if "feat" in sections else "patch" for section_issues in sections.values(): for issue in section_issues.values(): if issue["breaking"]: semver = "major" version_info = BumpVersion.get_version_info(semver) version_tag = version_info["new"] # TODO: take a note from bumpversion, read in versioning format string version_string = "v{version_tag}".format(version_tag=version_tag) w = writer.new_writer(extension, dry_run=dry_run, issue_link=config.get("issue_link")) w.add_version(version_string) for section in sorted(e.supported_sections): if section not in sections: continue header = e.supported_sections[section] w.add_section( header, {k: v["description"] for k, v in sections[section].items()}) click.echo(w) _finalise(w, e, version_tag, extension, dry_run=dry_run, release=release, commit=commit)