Skip to content

Commit 2710b98

Browse files
authored
Add success messages (#30)
Introduces a new logging level
2 parents eb3158a + 043d4dd commit 2710b98

File tree

9 files changed

+29
-19
lines changed

9 files changed

+29
-19
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ If you use, `pre-commit`, consider adding this repo as a hook to check for updat
145145

146146
```yaml
147147
- repo: https://github.com/George-Ogden/mirror-rorrim/
148-
rev: v0.4.6
148+
rev: v0.4.7
149149
hooks:
150150
- id: mirror-check
151151
```

mirror/installer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class MirrorInstaller(MirrorManager):
2727

2828
def install(self) -> None:
2929
self._run(self._install, keep_lock_on_failure=False)
30+
logger.success("Install complete!")
3031

3132
def _install(self) -> None:
3233
self.checkout_all()

mirror/logger.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,14 @@ def wrapper(*args: P.args, **kwargs: P.kwargs) -> R:
9090

9191
def log_level_name(quiet: int, verbose: int) -> str | int:
9292
match verbose - quiet:
93-
case -3:
93+
case -4:
9494
return "CRITICAL"
95-
case -2:
95+
case -3:
9696
return "ERROR"
97-
case -1:
97+
case -2:
9898
return "WARNING"
99+
case -1:
100+
return "SUCCESS"
99101
case 0:
100102
return "INFO"
101103
case 1:

mirror/logger_test.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,21 +181,23 @@ def log(x: int) -> int:
181181
# -vvvv
182182
(0, 4, 0),
183183
# -q
184-
(1, 0, "warning"),
184+
(1, 0, "success"),
185185
# -qq
186-
(2, 0, "error"),
186+
(2, 0, "warning"),
187187
# -qqq
188-
(3, 0, "critical"),
188+
(3, 0, "error"),
189189
# -qqqq
190-
(4, 0, 50),
190+
(4, 0, "critical"),
191191
# -qqqqq
192192
(5, 0, 50),
193+
# -qqqqqq
194+
(6, 0, 50),
193195
# mixed equally
194196
(1, 1, "info"),
195197
# mixed verbose
196198
(1, 2, "debug"),
197199
# mixed quiet
198-
(3, 1, "error"),
200+
(4, 1, "error"),
199201
],
200202
)
201203
def test_log_level_name(quiet: int, verbose: int, level: str | int) -> None:

mirror/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def main(*args: P.args, **kwargs: P.kwargs) -> None:
5050
"-q",
5151
"--quiet",
5252
count=True,
53-
help="Display less output (repeat up to 3 times).",
53+
help="Display less output (repeat up to 4 times).",
5454
show_default=False,
5555
)
5656
@check_for_errors

mirror/main_test.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def remove_git_data(local: GitDir) -> None:
3535
# abs path to config
3636
"install --config .mirror.yaml",
3737
0,
38-
snapshot(""),
38+
snapshot("Install complete!"),
3939
"installer_tests/empty_repo_with_config",
4040
),
4141
(
@@ -69,7 +69,7 @@ def remove_git_data(local: GitDir) -> None:
6969
# abs path + remote (valid)
7070
"install --config-repo https://github.com/George-Ogden/mirror-rorrim-test-data/ --config-file /config-only.yaml",
7171
0,
72-
snapshot(""),
72+
snapshot("Install complete!"),
7373
None,
7474
),
7575
(
@@ -103,22 +103,24 @@ def remove_git_data(local: GitDir) -> None:
103103
# overwrite local mirror file
104104
"install -C https://github.com/George-Ogden/mirror-rorrim-test-data --config-file config-only.yaml",
105105
0,
106-
snapshot("'.mirror.yaml' has been overwritten during installation."),
106+
snapshot(
107+
"'.mirror.yaml' has been overwritten during installation. Install complete!"
108+
),
107109
"installer_tests/remote_config_overwrite",
108110
),
109111
(
110112
# overwrite local mirror file with itself
111113
"install",
112114
0,
113-
snapshot(""),
115+
snapshot("Install complete!"),
114116
"installer_tests/remote_config_overwrite",
115117
),
116118
# check tests
117119
(
118120
# works fine
119121
"check",
120122
0,
121-
snapshot(""),
123+
snapshot("All up to date!"),
122124
"checker_tests/up_to_date",
123125
),
124126
(
@@ -142,7 +144,7 @@ def remove_git_data(local: GitDir) -> None:
142144
# works fine
143145
"sync",
144146
0,
145-
snapshot(""),
147+
snapshot("All synced!"),
146148
"syncer_tests/behind",
147149
),
148150
(
@@ -177,7 +179,7 @@ def remove_git_data(local: GitDir) -> None:
177179
"sync",
178180
0,
179181
snapshot(
180-
"'.mirror.yaml' modified while syncing. Please merge any conflicts then rerun to sync any added files."
182+
"'.mirror.yaml' modified while syncing. Please merge any conflicts then rerun to sync any added files. All synced!"
181183
),
182184
"syncer_tests/update_mirror",
183185
),

mirror/mirror.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def check(self) -> ExitCode:
3636
self.checkout_all()
3737
up_to_date = self.all_up_to_date()
3838
if up_to_date:
39-
logger.info("All up to date!")
39+
logger.success("All up to date!")
4040
return int(not up_to_date)
4141

4242
def all_up_to_date(self) -> bool:

mirror/syncer.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
from dataclasses import dataclass
22

3+
from loguru import logger
4+
35
from .manager import ExistingMirrorManager
46

57

68
@dataclass(frozen=True)
79
class MirrorSyncer(ExistingMirrorManager):
810
def sync(self) -> None:
911
self._run(self._sync, keep_lock_on_failure=True)
12+
logger.success("All synced!")
1013

1114
def _sync(self) -> None:
1215
self.checkout_all()

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.4.6
1+
0.4.7

0 commit comments

Comments
 (0)