Repository navigation
refactor: split importcheck.go and share the --when rules with import - #438
Merged
Merged
Conversation
…-back A pure move: importvalidate.go holds the pre-write checks and the refusal error, importdest.go the destination resolution, and importreadback.go the read-back and its error. importcheck.go keeps the shared types and the payload walk.
ImpossibleWhenError now carries a reason, so import words its own message from NormalizeWhen's verdict instead of keeping its own clock regexes, timed keywords and anytime/someday branch. The timed-keyword check is exported as things.TimedWhenKeyword, and payloadType maps a payload's type to a TaskType for prepareImport and importCreates. The two grammars differed on one input: a 12-hour time with two or more spaces before am/pm, which import refused and add sent. add now refuses it too, since neither form was measured in Things.
ryanlewis
force-pushed
the
refactor/import-split
branch
from
October 9, 2026 23:34
2560ce6 to
8a77af4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two steps, one commit each (plus a review commit).
Split importcheck.go (pure move). The 1,900-line file is now split by job:
importvalidate.go: the pre-write checks (prepareImport, thebadImport*andfutureImportDateschecks) and the refusal errorimportdest.go: destination resolution (resolveImportDests,importCreates,importTo)importreadback.go: the read-back (readBackCreates,unconfirmShared,checkClosedAt,checkWhens) and its errorimportcheck.go: the shared types and the payload walkcreatedDest.fitsstays in verify.go becauseadduses it too. A sorted-line comparison shows the old and new files differ only in their import blocks.Import uses the shared
--whenrules.ImpossibleWhenErrornow carries aReason, so import words its own message fromNormalizeWhen's verdict. That removes import's copied clock regexes (importClock24/importClock12),realClock,importTimedWhensand the anytime/someday branch. The timed-keyword check is exported asthings.TimedWhenKeyword. Import keeps its own narrower payload rules: a when or deadline starting with a digit must be a two-digitYYYY-MM-DD, onlytoday,tomorrow,eveningor a date may come before an@, and a bare time or ISO date-time is refused. A newpayloadTypehelper maps a payload item'stypeto a task type inprepareImport,importCreates,badImportScheduleandbadImportTypes.A new 50-row table test in
importvalidate_test.gocovers import's when and deadline rules and their exact refusal messages. I wrote it before the switch, and it passes unchanged after it.Behaviour change.
add --when(andedit --when) now refuse a 12-hour time with two or more spaces before am/pm, such astoday@6 pm,today@9:30 pmor a bare9:30 pm. Import already refused these, while add passed them to Things. Neither form has been tested in Things, so both now refuse it. One space (6 pm,9:30 PM) is still accepted. The docs only show times with no space (9:30PM,6pm), so they need no change.make testandmake lintpass.