Determine the work specification. The work may come from the user's prompt directly,
from someone's feedback on the PR, from the descriptions and comments of issues fixed
by the PR, or from the PR itself (title and description).
Even when the prompt is the primary specification, do not proceed from the
prompt alone. The fixed issue context, PR title, description, associated comments,
and code comments are important context, and can be retrieved as below:
| Context source | How to inspect |
|---|
| Fixed issues | tod issue list --query 'fixed in pull request "<pr-reference>"' -- save the output as <fixed-issues>. For each returned issue, inspect tod issue get <issue-reference> and tod issue get-comments <issue-reference>; note the issue title, description, and comments. |
| PR metadata, title, and description | tod pr get <pr-reference> -- note <source-project>, <source-branch>, <target-project>, <target-branch>, <merge-strategy>, <head-commit>, <status>, title, description, linked issues, submitter, reviewers, assignees, and current review status. |
| PR comments | tod pr get-comments <pr-reference> |
| Line-anchored code comments | tod pr get-code-comments <pr-reference> -- note id, file, line range, resolution state, and replies. |
Reuse <fixed-issues> later if squash-merge commit message composition
needs the same fixed-issue query result.
Then proceed to get your own login name:
tod get-login-name
Match your login name against the PR submitter, reviewers, assignees, and author of each PR comment,
code comment, and reply to understand your role, position, and previous involvements in
the context.
When the work is to investigate or fix failed builds, determine
<build-references> before assessment:
Inspect embedded resources. Download every linked image or file from
the PR description, PR discussion, and fixed issue descriptions/comments:
Assess, plan, and execute the work. Check the requested work against the current
code and behavior, plan appropriate actions, and execute it.
If the work is to review the PR, form the review following below procedure:
If the work is to merge the PR:
- If
<merge-strategy> is SQUASH_SOURCE_BRANCH_COMMITS, fetch the PR commit
message using Commit message composition.
- Save a merge action for later submission:
tod pr merge <pr-reference>
when no commit message is needed, or tod pr merge <pr-reference> --commit-message '<commit-message>' for squash merges.
If the work is to resolve merge conflicts:
If the work is to investigate or fix failed builds, process every selected
<build-reference> in <build-references>:
- Investigate every selected build and record its outcome. A single code
change may fix multiple builds, but do not skip a build without
confirming that its failure has the same cause.
- Gather and examine build evidence before planning code changes:
tod build get <build-reference>
tod build get-log <build-reference>
- Read the build detail and log content carefully to identify the failure.
Note the build
commitHash. The failure happened on that commit, while
fixes must be implemented in the current checked-out PR head; those
commits may differ. Use the build commit as failure evidence, and verify
whether each candidate fix still applies to the current checkout before
editing.
- If the log contains a statement like
Dependency build is required to be successful but failed: <dependency-build-reference>,
get the dependency build detail. If its commit hash is the same as the
current build, investigate or fix the dependency build failure instead;
repeat this process for same-commit dependency build failures. If the
dependency build's commit hash differs from the current build, conclude
that the current build failure is caused by this dependency build.
- If the log contains a statement like
<report-name>: found problems with severity <severity-level> or higher,
fetch the referenced problems report:
tod build get-code-problems <build-reference> <report-name> <severity-level>
Problems may point to workspace files, 1-based line ranges, or
non-workspace artifacts used by the project.
- Inspect referenced workspace files as necessary. Inspect
.onedev-buildspec.yml when job configuration may be involved, and
run below command to get its schema if you need to modify it:
tod build get-spec-schema
- If useful, inspect changes since the previous successful build:
tod build get-changes-since-success <build-reference>
- Implement any needed code changes in the current checkout. If no code
change is appropriate, draft the PR comment or review action explaining
the decision.
Do not run any tod command that changes PR discussion, review state, or
merge state during this workflow. After implementing a code change, or after
deciding that the right outcome is only a response or state change, draft
every planned PR comment, code-comment reply, resolve, unresolve, approval,
request-changes action, merge action, or other PR state change.
If code changes remain in the working copy, commit them locally before
presenting the result:
git status --porcelain
If the output is non-empty, compose the local commit message using
Commit message composition, then run:
git add -A
git commit -m '<subject>' -m '<body>'
git status --porcelain
The final status must be clean.
Save each planned action in <saved-pr-actions> (see Session handoff).
Preserve action type and parameters needed by submit-pull-request-work
step 6, for example:
- New line-anchored finding -- file, line range, comment text
- General PR feedback -- comment text
- Line-anchored thread --
comment-id, reply text
- Resolve or unresolve --
comment-id, note text
- Reviewer outcome -- approve or request-changes, with summary text when
applicable
- Merge outcome -- whether it needs
--commit-message, and the full message
when applicable
Draft all comment, reply, note, and review text in Markdown, as the
corresponding tod commands post Markdown text. Write entity references
as <type> <reference>, where type is issue, pr (or pull request),
or build. Use #123 in the same project, path/to/project#123 across
projects, or PROJ-123 when the project has a key. A bare #123 always
means an issue; never use it for a PR or build. These forms differ from
tod command arguments.
When code was changed, leave the working copy on the PR source branch with
the new local commits. For review-only or response-only work, leave the
checkout as prepared for inspection. In all cases, keep work ready for
submit-pull-request-work.