Skip to content

batches: use templating variable to control where batch change link appears in changeset body

Administrator requested to merge kr-aa/create-batch-change-link into main

Created by: courier-new

Closes #34496.

This adds support for a new templating variable, ${{ batch_change_link }}, which is only available in changesetTemplate.body. When present, it will be substituted with the link back to Sourcegraph: "Created by Sourcegraph batch change ...". If it is not present, the link will be appended to the end of the body (existing behavior).

The replacement happens from the reconciler layer instead of from the templating library, since we were already constructing the link to the batch change from here. This has the slight caveat that, at the template rendering layer, we want to retain the variable without any substitution, which we do by defining a function in the templating module that effectively ignores that variable when it is evaluated.

src-cli

Since this updates a method in the templating library, we will prepare a corresponding patch to bump the version of github.com/sourcegraph/sourcegraph/lib used in src-cli once this is merged to main.

Test plan

Additional tests have been added to verify the behavior of the new variable. I also manually created a batch change from a spec using the template variable, verified that the published result had the link in the correct place, and verified that re-executing the same spec did not produce an UPDATE action by the reconciler.

Merge request reports

Loading