--- title: "ADR 0031: GitOps comment arguments are split on the first command keyword only" --- * Status: accepted * Code: [`pkg/provider/provider.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/provider/provider.go) (`getPipelineRunAndBranchOrTagNameFromComment`, `getNameFromComment`, `GetPipelineRunAndBranchOrTagNameFromTestComment`) ## Context A GitOps comment carries a command (`/test`, `/retest`, `/cancel`, with the configured prefix) followed by an optional PipelineRun name, an optional `branch:` or `tag:` target and optional `key=value` parameters, for example `/test prname branch:nightly key=value`. A branch name may itself contain `/test`, `/retest` or `/cancel`. ## Decision * The comment is split with `strings.SplitN(comment, typeOfComment, 2)`, so only the first keyword is a separator and later occurrences stay in the argument text. * When the argument text contains `:`, it must contain `branch:` or `tag:`, otherwise parsing returns an error. `tag:` wins over `branch:`. The PipelineRun name is the first word before the first `:`. * Without `:`, the name is the first word of the first line after the command. * A name token containing `=` is a `key=value` parameter, not a name, and is returned as empty. * `GetPipelineRunAndBranchOrTagNameFromTestComment` classifies the comment itself with `opscomments.CommentEventType`, then maps every type that is not `TestSingle` or `TestAll` to the `retest` keyword. Nothing upstream has to classify first. ## Consequences * A branch such as `release/test-fix` after `/test branch:` is not cut apart. * The only argument check is that the text after the keyword contains `branch:` or `tag:` somewhere. Any other `word:value` pair is not rejected as long as one of those two is present elsewhere in the arguments, so `/test pr other:value branch:nightly` resolves branch `nightly`. * Calling the test-comment helper with a comment that is not a test or retest command silently parses it as `retest`.