Repository navigation
refactor(edit): decide whether an edit is sent in one place - #452
Merged
Merged
Conversation
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.
runEditdecided "will this edit be sent" twice, in two hand-written conditions: once before the tag check (to check the auth token before--create-tagsmakes a tag) and once at the no-op early return for an already-closed item. Both now go throughsendsEdit(already, reveal, changed), whose doc comment states the one rule: only an item already in the closed status asked for, with no--revealand nothing else to change, goes unsent.Before the tag check, the only change known is a tag
--create-tagswill make, so that check askssendsEdit(already, reveal, false) || createsTags(...). The tag lookup still runs only when the edit would otherwise go unsent, as before. After the no-op check,changedis the whole answer.Behaviour is unchanged.
Tests
TestEditAlreadyClosedWithChangeNeedsAuthToken: an already-closed item with--titleor--revealand no auth token is refused withupdate: auth token is required, and nothing runs. It passes on main and on this branch.TestSendsEditcovers the rule's four cases.TestEditAlreadyClosedNeedsNoAuthToken,TestEditAlreadyClosedExistingCreateTagsNeedsNoAuthTokenandTestEditMissingTokenRefusedBeforeTagsCreatedcover both checks and still pass./code-review
t.Run; fix the test comment.note: "X" is already completed; the status is left out of the editand then fails withauth token is required. A token check before the note would fix that. I left it as a follow-up.