@@ -51,13 +51,16 @@ class ACodeChecker(
5151 """Code checker."""
5252
5353 checks = (
54+ "changelogs_changes" ,
55+ "changelogs_pending" ,
5456 "extensions_fuzzed" ,
5557 "extensions_metadata" ,
5658 "extensions_registered" ,
5759 "glint" ,
5860 "python_yapf" ,
5961 "python_flake8" ,
60- "shellcheck" )
62+ "shellcheck" ,
63+ "version" )
6164
6265 @property
6366 def all_files (self ) -> bool :
@@ -192,6 +195,16 @@ def summary_class(self) -> Type[CodeCheckerSummary]:
192195 """CodeChecker's summary class."""
193196 return CodeCheckerSummary
194197
198+ @cached_property
199+ def version_history (self ) -> "abstract.AVersionHistoryCheck" :
200+ """VERSION_HISTORY checker."""
201+ return self .version_history_class (self .directory , fix = self .fix )
202+
203+ @property # type:ignore
204+ @abstracts .interfacemethod
205+ def version_history_class (self ) -> Type ["abstract.AVersionHistoryCheck" ]:
206+ raise NotImplementedError
207+
195208 @cached_property
196209 def yapf (self ) -> "abstract.AYapfCheck" :
197210 """YAPF checker."""
@@ -210,6 +223,41 @@ def add_arguments(self, parser: argparse.ArgumentParser) -> None:
210223 parser .add_argument ("-s" , "--since" )
211224 parser .add_argument ("--extensions_build_config" )
212225
226+ async def check_changelogs_changes (self ):
227+ for changelog in self .version_history .project .changelogs .values ():
228+ errors = self .version_history .version_file (
229+ self .version_history .project , changelog ).run_checks ()
230+ if errors :
231+ self .error ("changelogs" , errors )
232+ else :
233+ self .succeed ("changelogs" , [f"{ changelog .version } " ])
234+
235+ async def check_changelogs_pending (self ):
236+ pending = [
237+ k .base_version
238+ for k , v in self .version_history .project .changelogs .items ()
239+ if v .release_date == "Pending" ]
240+ all_good = (
241+ not pending
242+ or (self .version_history .project .is_dev
243+ and (pending
244+ == [self .version_history .project .version .base_version ])))
245+ if all_good :
246+ self .succeed ("pending" , ["No extraneous pending versions found" ])
247+ return
248+ pending = [
249+ x for x
250+ in pending
251+ if x != self .version_history .project .version .base_version ]
252+ if self .version_history .project .is_dev :
253+ self .error (
254+ "pending" ,
255+ [f"Only current version should be pending, found: { pending } " ])
256+ else :
257+ self .error (
258+ "pending" ,
259+ [f"Nothing should be pending, found: { pending } " ])
260+
213261 async def check_extensions_fuzzed (self ) -> None :
214262 """Check for glint issues."""
215263 if self .extensions .all_fuzzed :
@@ -258,6 +306,44 @@ async def check_shellcheck(self) -> None:
258306 """Check for shellcheck issues."""
259307 await self ._code_check (self .shellcheck )
260308
309+ async def check_version (self ) -> None :
310+ is_current = self .version_history .project .is_current (
311+ self .version_history .project .changelogs .current )
312+ if is_current :
313+ self .succeed (
314+ "version" ,
315+ ["VERSION.txt version matches most recent changelog" ])
316+ else :
317+ self .error (
318+ "version" ,
319+ ["VERSION.txt does not match most recent changelog" ])
320+ not_pending = (
321+ self .version_history .project .is_dev
322+ and not self .version_history .project .changelogs .is_pending )
323+ not_dev = (
324+ not self .version_history .project .is_dev
325+ and self .version_history .project .changelogs .is_pending )
326+ if not_pending :
327+ self .error (
328+ "version" ,
329+ ["VERSION.txt is set to `-dev` but most recent changelog "
330+ "is not `Pending`" ])
331+ elif not_dev :
332+ self .error (
333+ "version" ,
334+ ["VERSION.txt is not set to `-dev` but most recent changelog "
335+ "is `Pending`" ])
336+ elif self .version_history .project .is_dev :
337+ self .succeed (
338+ "version" ,
339+ ["VERSION.txt is set to `-dev` and most recent changelog "
340+ "is `Pending`" ])
341+ else :
342+ self .succeed (
343+ "version" ,
344+ ["VERSION.txt is not set to `-dev` and most recent "
345+ "changelog is not `Pending`" ])
346+
261347 @checker .preload (
262348 when = ["python_flake8" ],
263349 catches = [subprocess .exceptions .OSCommandError ])
0 commit comments