Skip to content

Commit

Permalink
Pipe the watch/serve message state directly into the metadata, so it'…
Browse files Browse the repository at this point in the history
…s handled correctly. Fixes #2761
  • Loading branch information
tabatkins committed Mar 8, 2024
1 parent 67b64a9 commit d765c69
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 2 additions & 3 deletions bikeshed/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,8 +556,6 @@ def handleWatch(options: argparse.Namespace, extras: list[str]) -> None:
from . import metadata
from .Spec import Spec

# Can't have an error killing the watcher
m.state.dieOn = "nothing"
doc = Spec(inputFilename=options.infile, token=options.ghToken)
if not doc.valid:
m.die("Spec is in an invalid state; exitting.")
Expand All @@ -572,12 +570,13 @@ def handleServe(options: argparse.Namespace, extras: list[str]) -> None:
from . import metadata
from .Spec import Spec

m.state.dieOn = "nothing"
doc = Spec(inputFilename=options.infile, token=options.ghToken)
if not doc.valid:
m.die("Spec is in an invalid state; exitting.")
return
doc.mdCommandLine = metadata.fromCommandLine(extras)
# Can't have an error killing the watcher
doc.mdCommandLine.addData("Die On", "nothing")
if options.byos:
doc.mdCommandLine.addData("Group", "byos")
doc.watch(outputFilename=options.outfile, port=int(options.port))
Expand Down
2 changes: 2 additions & 0 deletions bikeshed/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ def replace(self, **kwargs: t.Any) -> MessagesState:
return dataclasses.replace(self, seenMessages=set(), categoryCounts=Counter(), **kwargs)

def shouldDie(self, category: str, timing: str = "early") -> bool:
if self.dieWhen == "never":
return False
if self.dieWhen == "late" and timing == "early":
return False
deathLevel = MESSAGE_LEVELS[self.dieOn]
Expand Down

0 comments on commit d765c69

Please sign in to comment.