+1
CHANGELOG.md
+1
CHANGELOG.md
···
17
17
18
18
## other
19
19
- support for symlinking `autoconfig.yml` in addition to or instead of sourcing `config.py`
20
+
- `qbpm new --overwrite`: back up existing config files by moving to e.g. `config.py.bak`
20
21
- `contrib/qbpm.desktop`: add `MimeType` and `Keywords`, fix incorrect formatting of `Categories`
21
22
- allow help text to be slightly wider to avoid awkward line breaks
22
23
- macOS: fix detection of qutebrowser binary in /Applications
+9
-3
src/qbpm/profiles.py
+9
-3
src/qbpm/profiles.py
···
45
45
if not source.is_file():
46
46
return
47
47
user_config = profile.root / "config" / "config.py"
48
+
if overwrite and user_config.exists():
49
+
back_up(user_config)
48
50
with user_config.open(mode="w" if overwrite else "x") as dest_config:
49
51
out = partial(print, file=dest_config)
50
52
out(
···
70
72
if not source.is_file() or dest.resolve() == source.resolve():
71
73
return
72
74
if overwrite and dest.exists():
73
-
backup = Path(str(dest) + ".bak")
74
-
info(f"backing up existing autoconfig to {backup}")
75
-
dest.replace(backup)
75
+
back_up(dest)
76
76
dest.symlink_to(source)
77
+
78
+
79
+
def back_up(dest: Path) -> None:
80
+
backup = Path(str(dest) + ".bak")
81
+
info(f"backing up existing {dest.name} to {backup}")
82
+
dest.replace(backup)
77
83
78
84
79
85
def check(profile: Profile) -> bool:
+5
-6
tests/test_profiles.py
+5
-6
tests/test_profiles.py
···
70
70
url = "http://example.com"
71
71
config_dir = profile.root / "config"
72
72
config_dir.mkdir(parents=True)
73
+
config = config_dir / "config.py"
74
+
backup = config_dir / "config.py.bak"
73
75
profiles.create_config(profile, tmp_path, "")
74
76
profiles.create_config(profile, tmp_path, "", url, True)
75
-
assert list(config_dir.iterdir()) == [config_dir / "config.py"]
76
-
with (config_dir / "config.py").open() as conf:
77
-
for line in conf:
78
-
if url in line:
79
-
return
80
-
raise AssertionError()
77
+
assert set(config_dir.iterdir()) == {config, backup}
78
+
assert url in config.read_text()
79
+
assert url not in backup.read_text()
81
80
82
81
83
82
def test_link_autoconfig(tmp_path: Path):