|
4 | 4 |
|
5 | 5 | Batch Changes are created by writing a [batch spec](/batch-changes/batch-spec-yaml-reference) and executing that batch spec with the [Sourcegraph CLI](https://github.com/sourcegraph/src-cli) `src`. |
6 | 6 |
|
| 7 | +There are two ways of creating a batch change: |
| 8 | + |
| 9 | +1. On your Sourcegraph instance, with [server-side execution](#on-your-sourcegraph-instance) |
| 10 | +2. On your local machine, with the [Sourcegraph CLI](#using-the-sourcegraph-cli) |
| 11 | + |
| 12 | +## On your Sourcegraph instance |
| 13 | + |
| 14 | +Here, you'll learn how to create and run a batch change via server-side execution. |
| 15 | + |
| 16 | +To get started, click the **Batch Changes** icon in the top navigation or navigate to `/batch-changes`. |
| 17 | + |
| 18 | +### Create a batch change |
| 19 | + |
| 20 | +Click the **Create batch change** button on the Batch Changes page, or go to `/batch-changes/create`. |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | +You will be redirected to a page showing you a list of curated templates. |
| 25 | + |
| 26 | +### Choosing a template |
| 27 | + |
| 28 | +<Callout type="info">Templates is a feature available in Sourcegraph 6.6 and later.</Callout> |
| 29 | + |
| 30 | +From the template selection page, you can either: |
| 31 | + |
| 32 | +- **Pick a template** from the list of curated templates that best matches your use case |
| 33 | +- **Click "Start from Scratch"** if you prefer to continue without a template |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | +Your site admin can curate the list of available templates to match your organization's specific needs and use cases. |
| 38 | + |
| 39 | +### Filling out template fields |
| 40 | + |
| 41 | +If you selected a template, you will need to fill out the form fields specific to that template. These fields will customize the batch spec to your specific requirements. |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | +The form fields are validated by regular expressions. If the validation fails, look at the description of that field to see what kind of value is required. |
| 46 | + |
| 47 | +### Choose a name for your batch change |
| 48 | + |
| 49 | +After you've filled out the template form fields, or after you've clicked "Start from Scratch", you will be prompted to choose a name for your namespace and optionally define a custom namespace to put your batch change in. |
| 50 | + |
| 51 | + |
| 52 | + |
| 53 | +Once done, click **Create**. |
| 54 | + |
| 55 | +### Previewing batch spec and workspaces |
| 56 | + |
| 57 | +You can now see the batch spec and run a preview of the affected repositories and workspaces from the right-hand side panel. After resolution, it will show all the workspaces in repositories that match the given `on` statements. You can search through them and determine if your query is satisfying before starting execution. You can also exclude single workspaces from this list. |
| 58 | + |
7 | 59 | Batch Changes can also be used on [multiple projects within a monorepo](/batch-changes/creating-changesets-per-project-in-monorepos) by using the `workspaces` key in your batch spec. |
8 | 60 |
|
9 | | -There are two ways of creating a batch change: |
| 61 | +The library contains examples that you can apply right into your batch spec if you need inspiration. Your site admin can manage the library of examples. |
| 62 | + |
| 63 | + |
| 64 | + |
| 65 | +### Executing your batch spec |
| 66 | + |
| 67 | +When the spec is ready to run, ensure the [preview](/batch-changes/create-a-batch-change#previewing-workspaces) is up to date and then click **Run batch spec**. This takes you to the execution screen. On this page, you see: |
| 68 | + |
| 69 | +- Run statistics at the top |
| 70 | +- All the workspaces, including status and diff stat, in the left panel |
| 71 | +- Details on a particular workspace on the right-hand side panel where you can see steps with: |
| 72 | + - Logs |
| 73 | + - Results |
| 74 | + - Command |
| 75 | + - Per-step diffs |
| 76 | + - Output variables |
| 77 | + - Execution timelines for debugging |
| 78 | + |
| 79 | +Once finished, you can proceed to the batch spec preview, as you know it from before. |
| 80 | + |
| 81 | + |
10 | 82 |
|
11 | | -1. On your local machine, with the [Sourcegraph CLI](#create-a-batch-change-with-the-sourcegraph-cli) |
12 | | -2. Remotely, with [server-side execution](/batch-changes/server-side) |
| 83 | +### Previewing and applying the batch spec |
| 84 | + |
| 85 | +On this page, you can review the proposed changes. Once satisfied, click **Apply**. |
13 | 86 |
|
14 | | -## Create a batch change with the Sourcegraph CLI |
| 87 | +Congratulations, you ran your first batch change server-side 🎊 |
| 88 | + |
| 89 | + |
| 90 | + |
| 91 | +## Using the Sourcegraph CLI |
15 | 92 |
|
16 | 93 | This part of the guide will walk you through creating a batch change on your local machine with the Sourcegraph CLI. |
17 | 94 |
|
@@ -83,7 +160,7 @@ src batch preview -f YOUR_BATCH_SPEC.yaml |
83 | 160 |
|
84 | 161 | After you've applied a batch spec, you can [publish changesets](/batch-changes/publishing-changesets) to the code host when you're ready. This will turn the patches into commits, branches, and changesets (such as GitHub pull requests) for others to review and merge. |
85 | 162 |
|
86 | | -You can share the link to your batch change with other users if you want their help. Any user on your Sourcegraph instance can [view it in the batch changes list](/batch-changes/create-a-batch-change#viewing-batch-changes). |
| 163 | +You can share the link to your batch change with other users if you want their help. Any user on your Sourcegraph instance can [view it in the batch changes list](/batch-changes/view-batch-changes). |
87 | 164 |
|
88 | 165 | If a user viewing the batch change lacks read access to a repository in the batch change, they can only see [limited information about the changes to that repository](/batch-changes/permissions-in-batch-changes#repository-permissions-for-batch-changes) (and not the repository name, file paths, or diff). |
89 | 166 |
|
@@ -114,88 +191,3 @@ src batch preview -f your_batch_spec.yaml -namespace <SOURCEGRAPH_USERNAME_OR_OR |
114 | 191 | ``` |
115 | 192 |
|
116 | 193 | When creating a batch change server-side using the UI, you can select the namespace to which the batch change belongs when you create it. |
117 | | - |
118 | | -### Administration |
119 | | - |
120 | | -Once a batch change is open, any Sourcegraph user can view it. However, the namespace determines who can administer it, such as editing or deleting it. When a batch change is created in a user namespace, only that user (and site admins) can administer it. When a batch change is created in an organization namespace, all members of that organization (and site admins) can administer it. |
121 | | - |
122 | | -## Create a batch change with server-side execution |
123 | | - |
124 | | -Here, you'll learn how to create and run a batch change via server-side execution. |
125 | | - |
126 | | -Click the **Create batch change** button on the Batch Changes page, or go to `/batch-changes/create`. |
127 | | -You will be prompted to choose a name for your namespace and optionally define a custom namespace to put your batch change in. |
128 | | - |
129 | | - |
130 | | - |
131 | | -Once done, click **Create**. |
132 | | - |
133 | | -### Editing the spec file |
134 | | - |
135 | | -You should see the editor view now. This view consists of three main areas: |
136 | | - |
137 | | -- The library sidebar panel on the left |
138 | | -- The editor in the middle |
139 | | -- The workspaces preview panel on the right |
140 | | - |
141 | | - |
142 | | - |
143 | | -You can pick from the examples in the library pane to get started quickly or begin working on your batch spec in the editor right away. Site admins can configure the examples. The editor will provide documentation as you hover over tokens in the YAML spec and supports auto-completion. |
144 | | - |
145 | | -### Previewing workspaces |
146 | | - |
147 | | -Once satisfied or to test your batch change's scope, you can run a new preview from the right-hand side panel at any time. After resolution, it will show all the workspaces in repositories that match the given `on` statements. You can search through them and determine if your query is satisfying before starting execution. You can also exclude single workspaces from this list. |
148 | | - |
149 | | - |
150 | | - |
151 | | -### Executing your batch spec |
152 | | - |
153 | | -When the spec is ready to run, ensure the preview is up to date and then click **Run batch spec**. This takes you to the execution screen. On this page, you see: |
154 | | - |
155 | | -- Run statistics at the top |
156 | | -- All the workspaces, including status and diff stat, in the left panel |
157 | | -- Details on a particular workspace on the right-hand side panel where you can see steps with: |
158 | | - - Logs |
159 | | - - Results |
160 | | - - Command |
161 | | - - Per-step diffs |
162 | | - - Output variables |
163 | | - - Execution timelines for debugging |
164 | | - |
165 | | -Once finished, you can proceed to the batch spec preview, as you know it from before. |
166 | | - |
167 | | - |
168 | | - |
169 | | -### Previewing and applying the batch spec |
170 | | - |
171 | | -On this page, you can review the proposed changes and the operations taken by Sourcegraph on each changeset. Once satisfied, click **Apply**. |
172 | | - |
173 | | -Congratulations, you ran your first batch change server-side 🎊 |
174 | | - |
175 | | - |
176 | | - |
177 | | -## Viewing batch changes |
178 | | - |
179 | | -You can view a list by clicking the **Batch Changes** icon in the top navigation bar: |
180 | | - |
181 | | - |
182 | | - |
183 | | -### Title-based search |
184 | | - |
185 | | -You can search through your previously created batch changes by title. This search experience makes it much easier to find the batch change you’re looking for, especially when you have large volumes of batch changes to monitor. |
186 | | - |
187 | | -Start typing the keywords that match the batch change’s title, and you will see a list of relevant results. |
188 | | - |
189 | | - |
190 | | - |
191 | | -## Filtering Batch Changes |
192 | | - |
193 | | -You can also use the filters to switch between showing all open or closed Batch Changes. |
194 | | - |
195 | | - |
196 | | - |
197 | | -## Filtering changesets |
198 | | - |
199 | | -When looking at a batch change, you can search and filter the list of changesets with the controls at the top of the list: |
200 | | - |
201 | | - |
0 commit comments