Repository navigation
feat(jira): add worklogs to tickets - #158
Merged
Merged
Conversation
The time service will take worklogs and add them to Jira, so the shared client gains AddWorklog: it posts the start, with its own offset, and the time spent in whole seconds, keeping Jira's defaults. A key that isn't a Jira key fails before anything is sent, since it's a segment of the path; decision 125's rule moves from todos to the client as jira.IsKey. worklog-add splits in three (decision 189): this client step, poll-now and worklog-add.
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.
Brief
Goal. The shared Jira client adds a worklog to a ticket.
timewill then take one atPOST /time/worklogs(stepworklog-add), and the Time page will fill a missing day (fill-day). This is the 13th oftime-tracking's sixteen steps.Why three steps. The plan's
worklog-addtouched three packages: the Jira client, the shared poller (sotimepolls again right after a write, as decision 180 says) andtimeitself. AGENTS.md wants one package a step, so it splits in three (decision 189):jira-add-worklog,poll-nowandworklog-add.Scope.
jira.IsKey(s)reports whethersis a Jira key, by decision 125's rule. The rule moves from todos'todopackage, which now calls it.(*jira.Client).AddWorklog(ctx, key, worklog)posts torest/api/3/issue/{key}/worklog.startedin Jira's layout (2006-01-02T15:04:05.000-0700, with the start's own offset) andtimeSpentSecondsin whole seconds..or..can't move the path.dotakes the status it wants, and reads no answer when it's given none. A sharednewPostbuilds the JSON POSTs ofFetchandAddWorklog.Out of scope.
poll-now).time'sPOST /time/worklogs, its checks and its zone (worklog-add).fill-day).write:jira-work(decision 103 planned it): a question for the user's end review.Acceptance criteria.
AddWorklogsends one POST to<API>/rest/api/3/issue/WEB-9/worklog. It has Basic auth, JSONContent-TypeandAccept, no query, and the body{"started":"2026-10-26T09:00:00.000+0100","timeSpentSeconds":5400}. It returns nil on Jira's 201.startedkeeps the start's offset and milliseconds:+0000in UTC,-0230in Newfoundland in summer,.250for a quarter of a second.add a Jira worklog: <status>: 200, 204, 400, 401, 403, 404, 413 and 500."",.,..,web-9,WEB-0,WEB-9/x,WEB-9,WEB-9\n.IsKeytakes decision 125's keys and nothing else. Todos behave as before: their tests pass unchanged.Fetchbehaves as before: its tests pass unchanged.mise run checkis green.QA
addworklog_test.goandaddworklogfail_test.go;IsKey's tests sit inkey_test.go. For AC5 and AC7, the diff changes none of todos' tests orFetch's.do's wanted status and nil answer, and the 200 ofgetandfetch;newPost's method, body andContent-Type, plusAcceptand Basic auth;(?m), case, one-letter projects, ticket 0 and non-ASCII digits;TestAddWorklogFailsOnAnAddressItCantAsk. A request that can't be built was the one line ofAddWorklogno test reached.AddWorklogandnewPostare now fully covered:internal/jirawent from 98.1% to 99.4%. The failure tests moved toaddworklogfail_test.go, asFetch's live infetchfail_test.go, so both files stay well under 200 lines.POST /rest/api/3/issue/{issueIdOrKey}/worklogis operationaddWorklog;write:jira-work(or a set of granular beta scopes);notifyUsersdefaults totrueandadjustEstimatetoauto;"started": "2021-01-17T12:34:00.000+0000"withtimeSpentSeconds.AddWorkloguntilworklog-add, and the tests already talk to a real HTTP server on loopback. The work Jira wasn't touched.mise run checkis green:internal/jira99.4%);Review
No blocking findings.
startedLayout's comment said the layout was only for Jira's answers. It now names new worklogs too.AddWorklogsends whatever time it's given. Less than a second becomes 0, which Jira refuses with a 400.worklog-addwill check for 1 to 1,440 minutes first.todostore now imports the Jira client's package for the key rule. A package of its own for one regexp would be a speculative split, and a key is a Jira concept.get's request-building error is still unreached. That's older than this step.Merged under the user's standing OK (2026-10-26): merge once CI's
checkis green, and review everything at the end.