Skip to content

Commit 456a1fc

Browse files
authored
Merge pull request #542 from linear-b/fix-pr-context
added pr source
2 parents 26573b9 + d0263c7 commit 456a1fc

File tree

1 file changed

+36
-35
lines changed

1 file changed

+36
-35
lines changed

docs/context-variables.md

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ Context variable are the inputs for the automation conditions or checks.
99
!!! Legend
1010

1111
The icons indicate the availability status of each action.
12-
13-
- :fontawesome-brands-github: Supported on GitHub
14-
- :fontawesome-brands-gitlab: Supported on GitLab
12+
13+
- :fontawesome-brands-github: Supported on GitHub
14+
- :fontawesome-brands-gitlab: Supported on GitLab
1515
- :octicons-beaker-24: Under development and not available yet.
1616
- :fontawesome-solid-flask: Open beta - Under development and currently available for all
1717

1818
## Overview
1919

2020
### Context
2121

22-
gitStream includes a collection of variables called contexts.
22+
gitStream includes a collection of variables called contexts.
2323

2424
- [`branch`](#branch) :fontawesome-brands-github: :fontawesome-brands-gitlab:
2525
- [`env`](#env) :fontawesome-solid-flask: :fontawesome-brands-github:
@@ -92,9 +92,9 @@ The following structures are used in the context objects:
9292

9393
#### `branch`
9494

95-
The `branch` context contains info regarding the branch changes compared to the base branch.
95+
The `branch` context contains info regarding the branch changes compared to the base branch.
9696

97-
!!! note
97+
!!! note
9898

9999
compared to the `source` context does not include actual source code.
100100

@@ -134,7 +134,7 @@ automations:
134134

135135
!!! tip
136136

137-
The `files` context doesn't include deleted file, to identify both modified and deleted files use the `branch.diff.files_metadata`, for example:
137+
The `files` context doesn't include deleted file, to identify both modified and deleted files use the `branch.diff.files_metadata`, for example:
138138
```
139139
{{ branch.diff.files_metadata | match(attr='file', regex=r/\.md$/) | every }}
140140
```
@@ -144,7 +144,7 @@ automations:
144144
The `env` context allows the user to pass data from the repo that is unavailable in the other context variables. Thus, the structure of the variable is not fixed and depends on user configuration.
145145

146146
To configure the `env` variable, add the `env` field to gitstream's workflow job configurations on `.github/workflows/gitstream.yml`. For more information, visit GitHub's guide for [Using secrets in GitHub Actions](https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions)
147-
147+
148148
```yaml title="examle: add secrets to the env variable"
149149
...
150150
jobs:
@@ -181,7 +181,7 @@ The `files` context includes the list of changed files in the branch compared to
181181
|---------|-----------|------------------------ |
182182
| `files` | [String] | List of all changed files with their full path |
183183

184-
For example, a typical `files` context can look like this:
184+
For example, a typical `files` context can look like this:
185185

186186
```json
187187
[
@@ -233,6 +233,7 @@ The `pr` context includes metadata related to the pull request.
233233
| `pr.number` | Integer | The PR or MR Id number |
234234
| `pr.provider` | String | The Git cloud provider name, e.g. `GitHub`, `GitLab` etc. |
235235
| `pr.reviewers` | [String] | The list of reviewers set for this PR |
236+
| `pr.source` | String | The branch from which the PR originates |
236237
| `pr.status` | String | The PR status: `open`, `closed` and `merged` |
237238
| `pr.target` | String | The branch the PR is intended merged into |
238239
| `pr.title` | String | The PR title |
@@ -277,7 +278,7 @@ The `repo` context includes metadata related to the repo.
277278

278279
#### `source`
279280

280-
The `source` context includes a list of `FileDiff` objects that can be used to get insights based on code changes. The changes compared to the latest main branch.
281+
The `source` context includes a list of `FileDiff` objects that can be used to get insights based on code changes. The changes compared to the latest main branch.
281282

282283
| Values | Type | Description |
283284
|---------------------|-------|--------------------------------------------------- |
@@ -292,30 +293,30 @@ The source context include all code changes, it is not safe to share it with unk
292293
"name": String, # The check name
293294
"status": String, # The check status: `queued`, `in_progress`, `completed`
294295
"conclusion": String, # The check conclusion: `action_required`, `cancelled`, `failure` `neutral`, `success`, `skipped`, `stale`, `timed_out`
295-
}
296+
}
296297
```
297298

298299
#### `Comment` structure
299300

300301
```json
301302
{
302303
"commenter": String, # The user that add the comment
303-
"content": String, # The comment body
304+
"content": String, # The comment body
304305
"created_at": String, # The time on which the comment was created
305306
"updated_at": String, # The time on which the comment was last updated
306-
}
307+
}
307308
```
308309

309310
#### `Conversation` structure
310311

311312
```json
312313
{
313-
"commenter": String, # The user that add the comment
314-
"content": String, # The comment body
315-
"created_at": String, # The time on which the comment was created
316-
"updated_at": String, # The time on which the comment was updated
317-
"start_line": Integer, # The first line marked for this comment
318-
"end_line": Integer, # The last line marked for this comment
314+
"commenter": String, # The user that add the comment
315+
"content": String, # The comment body
316+
"created_at": String, # The time on which the comment was created
317+
"updated_at": String, # The time on which the comment was updated
318+
"start_line": Integer, # The first line marked for this comment
319+
"end_line": Integer, # The last line marked for this comment
319320
"is_resolved": Boolean # `true` when marked as resolved
320321
}
321322
```
@@ -327,7 +328,7 @@ The `repo.contributors` mapping includes a list of `Contributor`, where the user
327328
```json
328329
{
329330
USER_NAME: Integer # Number of commits
330-
}
331+
}
331332
```
332333

333334
#### `FileDiff` structure
@@ -341,7 +342,7 @@ The `source.diff.files` mapping includes a list of `FileDiff`:
341342
"new_file": String, # The name of the file after the changes, including its path
342343
"original_content": String, # The content as is in the `main` branch
343344
"original_file": String, # The name of the file before the changes, including its path
344-
}
345+
}
345346
```
346347

347348
#### `FileMetadata` structure
@@ -351,9 +352,9 @@ The `branch.diff.files_metadata` mapping includes a list of `FileMetadata`:
351352
```json
352353
{
353354
"additions": Integer, # The number of lines edited or added to the file
354-
"deletions": Integer, # The number of lines removed from the file
355+
"deletions": Integer, # The number of lines removed from the file
355356
"file": String, # The name of the file before the changes, including its path
356-
}
357+
}
357358
```
358359

359360
For example, sum additions in javascript code files:
@@ -369,35 +370,35 @@ This structure include per changed file, for every user, the number of lines cha
369370
```json
370371
{
371372
FILE_NAME: # The file name and path
372-
{
373+
{
373374
# The git user identifier (String)
374375
GIT_USER: {
375376
"week_INDEX": Integer # Number of lines changed that week
376-
# ... for the last 52 weeks
377+
# ... for the last 52 weeks
377378
}
378379
}
379380
}
380381
```
381382

382-
For example:
383+
For example:
383384

384385
```json
385386
{
386387
"src/utils/service.js": {
387388
"popeye <[email protected]>": {
388-
"week_1": 20,
389-
"week_2": 15,
389+
"week_1": 20,
390+
"week_2": 15,
390391
"week_10": 250
391392
},
392393
"olive <[email protected]>": {
393-
"week_1": 3,
394-
"week_3": 50,
394+
"week_1": 3,
395+
"week_3": 50,
395396
"week_52": 250
396397
}
397398
},
398399
"README.md": {
399400
"popeye <[email protected]>": {
400-
"week_2": 15,
401+
"week_2": 15,
401402
"week_3": 10
402403
}
403404
}
@@ -411,14 +412,14 @@ For each file, a list of user's blame ratio.
411412
```json
412413
{
413414
FILE_NAME: # The file name and path
414-
{
415+
{
415416
# The git user identifier (String)
416417
GIT_USER: Integer, # Precentage 0-100, ratio of user's lines / total lines in file
417418
}
418419
}
419420
```
420421

421-
For example:
422+
For example:
422423

423424
```json
424425
{
@@ -439,9 +440,9 @@ For example:
439440
```json
440441
{
441442
"commenter": String, # The user that add the comment
442-
"content": String, # The comment body
443+
"content": String, # The comment body
443444
"created_at": String, # The time on which the comment was created
444445
"state": String, # Either `approved`, `changes_requested`, `commented`, `pending`, `submitted`
445446
"conversations": [Conversation], # Conversations that are relvant to this Review feedback
446-
}
447+
}
447448
```

0 commit comments

Comments
 (0)