Skip to content

Commit

Permalink
Actually remove setup.cfg from bumpversion configuration when using w…
Browse files Browse the repository at this point in the history
…hey as the build backend.
  • Loading branch information
domdfcoding committed Apr 5, 2021
1 parent 9c64aef commit f535e5f
Show file tree
Hide file tree
Showing 19 changed files with 130 additions and 163 deletions.
17 changes: 10 additions & 7 deletions repo_helper/files/ci_cd.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,19 +567,21 @@ def ensure_bumpversion(repo_path: pathlib.Path, templates: jinja2.Environment) -
bv.read(str(bumpversion_file))

old_sections = ["bumpversion:file:git_helper.yml"]
required_sections = [f"bumpversion:file:{filename}" for filename in get_bumpversion_filenames(templates)]
required_sections = {f"bumpversion:file:{filename}" for filename in get_bumpversion_filenames(templates)}

if not templates.globals["enable_docs"]:
old_sections.append(f"bumpversion:file:{templates.globals['docs_dir']}/index.rst")

if templates.globals["use_whey"]:
old_sections.append(f"bumpversion:file:setup.cfg")
old_sections.append("bumpversion:file:setup.cfg")

for section in old_sections:
if section in bv.sections():
bv.remove_section(section)
if section in required_sections:
required_sections.remove(section)

for section in required_sections:
for section in sorted(required_sections):
if section not in bv.sections():
bv.add_section(section)

Expand All @@ -590,10 +592,11 @@ def ensure_bumpversion(repo_path: pathlib.Path, templates: jinja2.Environment) -
init_section["search"] = ': str = "{current_version}"'
init_section["replace"] = ': str = "{new_version}"'

setup_cfg_section = bv["bumpversion:file:setup.cfg"]
if "search" not in setup_cfg_section:
setup_cfg_section["search"] = "name = {current_version}"
setup_cfg_section["replace"] = "name = {new_version}"
if "bumpversion:file:setup.cfg" in bv.sections():
setup_cfg_section = bv["bumpversion:file:setup.cfg"]
if "search" not in setup_cfg_section:
setup_cfg_section["search"] = "name = {current_version}"
setup_cfg_section["replace"] = "name = {new_version}"

bv["bumpversion"]["current_version"] = templates.globals["version"]
bv["bumpversion"]["commit"] = "True"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ current_version = 1.2.3
commit = True
tag = True

[bumpversion:file:pyproject.toml]

[bumpversion:file:repo_helper.yml]
[bumpversion:file:README.rst]

[bumpversion:file:__pkginfo__.py]

[bumpversion:file:README.rst]
[bumpversion:file:hello_world/__init__.py]
search = : str = "{current_version}"
replace = : str = "{new_version}"

[bumpversion:file:pyproject.toml]

[bumpversion:file:repo_helper.yml]

[bumpversion:file:setup.cfg]
search = name = {current_version}
replace = name = {new_version}

[bumpversion:file:hello_world/__init__.py]
search = : str = "{current_version}"
replace = : str = "{new_version}"
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ current_version = 1.2.3
commit = True
tag = True

[bumpversion:file:pyproject.toml]

[bumpversion:file:repo_helper.yml]
[bumpversion:file:README.rst]

[bumpversion:file:__pkginfo__.py]

[bumpversion:file:README.rst]
[bumpversion:file:hello_world/__init__.py]
search = : str = "{current_version}"
replace = : str = "{new_version}"

[bumpversion:file:pyproject.toml]

[bumpversion:file:repo_helper.yml]

[bumpversion:file:setup.cfg]
search = name = {current_version}
replace = name = {new_version}

[bumpversion:file:hello_world/__init__.py]
search = : str = "{current_version}"
replace = : str = "{new_version}"
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ current_version = 1.2.3
commit = True
tag = True

[bumpversion:file:pyproject.toml]

[bumpversion:file:repo_helper.yml]

[bumpversion:file:__pkginfo__.py]

[bumpversion:file:README.rst]

[bumpversion:file:setup.cfg]
search = name = {current_version}
replace = name = {new_version}
[bumpversion:file:__pkginfo__.py]

[bumpversion:file:doc-source/index.rst]

[bumpversion:file:hello_world/__init__.py]
search = : str = "{current_version}"
replace = : str = "{new_version}"

[bumpversion:file:pyproject.toml]

[bumpversion:file:repo_helper.yml]

[bumpversion:file:setup.cfg]
search = name = {current_version}
replace = name = {new_version}
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ current_version = 1.2.3
commit = True
tag = True

[bumpversion:file:pyproject.toml]

[bumpversion:file:repo_helper.yml]

[bumpversion:file:__pkginfo__.py]

[bumpversion:file:README.rst]

[bumpversion:file:setup.cfg]
search = name = {current_version}
replace = name = {new_version}
[bumpversion:file:__pkginfo__.py]

[bumpversion:file:doc-source/index.rst]

[bumpversion:file:hello_world/__init__.py]
search = : str = "{current_version}"
replace = : str = "{new_version}"

[bumpversion:file:pyproject.toml]

[bumpversion:file:repo_helper.yml]

[bumpversion:file:setup.cfg]
search = name = {current_version}
replace = name = {new_version}
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,14 @@ current_version = 1.2.3
commit = True
tag = True

[bumpversion:file:pyproject.toml]

[bumpversion:file:repo_helper.yml]

[bumpversion:file:__pkginfo__.py]

[bumpversion:file:README.rst]

[bumpversion:file:setup.cfg]
search = name = {current_version}
replace = name = {new_version}
[bumpversion:file:__pkginfo__.py]

[bumpversion:file:hello_world/__init__.py]
search = : str = "{current_version}"
replace = : str = "{new_version}"

[bumpversion:file:pyproject.toml]

[bumpversion:file:repo_helper.yml]
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,14 @@ current_version = 1.2.3
commit = True
tag = True

[bumpversion:file:pyproject.toml]

[bumpversion:file:repo_helper.yml]

[bumpversion:file:__pkginfo__.py]

[bumpversion:file:README.rst]

[bumpversion:file:setup.cfg]
search = name = {current_version}
replace = name = {new_version}
[bumpversion:file:__pkginfo__.py]

[bumpversion:file:hello_world/__init__.py]
search = : str = "{current_version}"
replace = : str = "{new_version}"

[bumpversion:file:pyproject.toml]

[bumpversion:file:repo_helper.yml]
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,16 @@ current_version = 1.2.3
commit = True
tag = True

[bumpversion:file:pyproject.toml]

[bumpversion:file:repo_helper.yml]

[bumpversion:file:__pkginfo__.py]

[bumpversion:file:README.rst]

[bumpversion:file:setup.cfg]
search = name = {current_version}
replace = name = {new_version}
[bumpversion:file:__pkginfo__.py]

[bumpversion:file:doc-source/index.rst]

[bumpversion:file:hello_world/__init__.py]
search = : str = "{current_version}"
replace = : str = "{new_version}"

[bumpversion:file:pyproject.toml]

[bumpversion:file:repo_helper.yml]
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,16 @@ current_version = 1.2.3
commit = True
tag = True

[bumpversion:file:pyproject.toml]

[bumpversion:file:repo_helper.yml]

[bumpversion:file:__pkginfo__.py]

[bumpversion:file:README.rst]

[bumpversion:file:setup.cfg]
search = name = {current_version}
replace = name = {new_version}
[bumpversion:file:__pkginfo__.py]

[bumpversion:file:doc-source/index.rst]

[bumpversion:file:hello_world/__init__.py]
search = : str = "{current_version}"
replace = : str = "{new_version}"

[bumpversion:file:pyproject.toml]

[bumpversion:file:repo_helper.yml]
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ current_version = 1.2.3
commit = True
tag = True

[bumpversion:file:pyproject.toml]

[bumpversion:file:repo_helper.yml]
[bumpversion:file:README.rst]

[bumpversion:file:__pkginfo__.py]

[bumpversion:file:README.rst]
[bumpversion:file:hello_world/__init__.py]
search = : str = "{current_version}"
replace = : str = "{new_version}"

[bumpversion:file:pyproject.toml]

[bumpversion:file:repo_helper.yml]

[bumpversion:file:setup.cfg]
search = name = {current_version}
replace = name = {new_version}

[bumpversion:file:hello_world/__init__.py]
search = : str = "{current_version}"
replace = : str = "{new_version}"
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ current_version = 1.2.3
commit = True
tag = True

[bumpversion:file:pyproject.toml]

[bumpversion:file:repo_helper.yml]
[bumpversion:file:README.rst]

[bumpversion:file:__pkginfo__.py]

[bumpversion:file:README.rst]
[bumpversion:file:hello_world/__init__.py]
search = : str = "{current_version}"
replace = : str = "{new_version}"

[bumpversion:file:pyproject.toml]

[bumpversion:file:repo_helper.yml]

[bumpversion:file:setup.cfg]
search = name = {current_version}
replace = name = {new_version}

[bumpversion:file:hello_world/__init__.py]
search = : str = "{current_version}"
replace = : str = "{new_version}"
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ current_version = 1.2.3
commit = True
tag = True

[bumpversion:file:pyproject.toml]

[bumpversion:file:repo_helper.yml]

[bumpversion:file:__pkginfo__.py]

[bumpversion:file:README.rst]

[bumpversion:file:setup.cfg]
search = name = {current_version}
replace = name = {new_version}
[bumpversion:file:__pkginfo__.py]

[bumpversion:file:doc-source/index.rst]

[bumpversion:file:hello_world/__init__.py]
search = : str = "{current_version}"
replace = : str = "{new_version}"

[bumpversion:file:pyproject.toml]

[bumpversion:file:repo_helper.yml]

[bumpversion:file:setup.cfg]
search = name = {current_version}
replace = name = {new_version}
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ current_version = 1.2.3
commit = True
tag = True

[bumpversion:file:pyproject.toml]

[bumpversion:file:repo_helper.yml]

[bumpversion:file:__pkginfo__.py]

[bumpversion:file:README.rst]

[bumpversion:file:setup.cfg]
search = name = {current_version}
replace = name = {new_version}
[bumpversion:file:__pkginfo__.py]

[bumpversion:file:doc-source/index.rst]

[bumpversion:file:hello_world/__init__.py]
search = : str = "{current_version}"
replace = : str = "{new_version}"

[bumpversion:file:pyproject.toml]

[bumpversion:file:repo_helper.yml]

[bumpversion:file:setup.cfg]
search = name = {current_version}
replace = name = {new_version}
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,14 @@ current_version = 1.2.3
commit = True
tag = True

[bumpversion:file:pyproject.toml]

[bumpversion:file:repo_helper.yml]

[bumpversion:file:__pkginfo__.py]

[bumpversion:file:README.rst]

[bumpversion:file:setup.cfg]
search = name = {current_version}
replace = name = {new_version}
[bumpversion:file:__pkginfo__.py]

[bumpversion:file:hello_world/__init__.py]
search = : str = "{current_version}"
replace = : str = "{new_version}"

[bumpversion:file:pyproject.toml]

[bumpversion:file:repo_helper.yml]
Loading

0 comments on commit f535e5f

Please sign in to comment.