Skip to content

Commit

Permalink
also allow recursive glob with **
Browse files Browse the repository at this point in the history
  • Loading branch information
balrok authored and Carl Mai committed Aug 7, 2020
1 parent a96ebf4 commit 0bd8d83
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bumpversion/cli.py
Expand Up @@ -356,7 +356,7 @@ def _load_configuration(config_file, explicit_config, defaults):

version_config = VersionConfig(**section_config)
if section_type.get("file") == "glob":
for filename_glob in glob.glob(filename):
for filename_glob in glob.glob(filename, recursive=True):
files.append(ConfiguredFile(filename_glob, version_config))
else:
files.append(ConfiguredFile(filename, version_config))
Expand Down
16 changes: 16 additions & 0 deletions tests/test_cli.py
Expand Up @@ -305,6 +305,22 @@ def test_glob_keyword(tmpdir, configfile):
assert "0.9.35" == tmpdir.join("file1.txt").read()
assert "0.9.35" == tmpdir.join("file2.txt").read()

def test_glob_keyword_recursive(tmpdir, configfile):
tmpdir.mkdir("subdir").mkdir("subdir2")
file1 = tmpdir.join("subdir").join("file1.txt")
file1.write("0.9.34")
file2 = tmpdir.join("subdir").join("subdir2").join("file2.txt")
file2.write("0.9.34")
tmpdir.join(configfile).write("""[bumpversion]
current_version: 0.9.34
new_version: 0.9.35
[bumpversion:glob:**/*.txt]""")

tmpdir.chdir()
main(["patch"])
assert "0.9.35" == file1.read()
assert "0.9.35" == file2.read()


def test_file_keyword_with_suffix_is_accepted(tmpdir, configfile, file_keyword):
tmpdir.join("file2").write("0.10.2")
Expand Down

0 comments on commit 0bd8d83

Please sign in to comment.