Skip to content

Commit c7ab6c2

Browse files
committed
added readfile filter
1 parent c157530 commit c7ab6c2

File tree

1 file changed

+42
-42
lines changed

1 file changed

+42
-42
lines changed

docs/filter-functions.md

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The following functions are supported in addition to the built-in functions prov
2020

2121
| Function | Input | Args | Output |
2222
| -------------------------------------------------------------------------------------------------------------- | ---------------------- | ------------------------------- | ---------------------- |
23-
| [`capture`](#capture)<br />Find and return the first occurrence of a regex in the input string | String | `regex` | String |
23+
| [`capture`](#capture)<br />Find and return the first occurrence of a regex in the input string | String | `regex` | String |
2424
| [`difference`](#difference)<br />Given two lists, keep only items that are in the 1st list but not in the 2nd. | [Objects] | `list` | [Objects] |
2525
| [`every`](#every)<br />Checks whether all element in the list are `true` | [Bool] | - | Bool |
2626
| [`filter`](#filter)<br />Reduce list of items into a list of same items that match the specified term | [String]<br />[Object] | `regex`, `term`, `list`, `attr` | [String]<br />[Object] |
@@ -31,34 +31,34 @@ The following functions are supported in addition to the built-in functions prov
3131
| [`nope`](#nope)<br />Checks whether all element in the list are `false` | [Bool] | - | Bool |
3232
| [`reject`](#reject)<br />Inverse of [`filter`](#filter), the result list contains non-matching items | [String]<br />[Object] | `regex`, `term`, `list`, `attr` | [String]<br />[Object] |
3333
| [`some`](#some)<br />Checks whether at least one element in the list is `true` | [Bool] | - | Bool |
34-
| [`readFile`](#readfile)<br />Reads the contents of a file from the current branch or "cm" folder | String | `path` | String |
34+
3535

3636
</div>
3737

3838
### High level functions
3939

4040
<div class="big-summary" markdown=1>
4141

42-
| Function | Input | Args | Output |
43-
| ----------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------- | ----------------------- |
44-
| [`allDocs`](#alldocs)<br />Checks the list includes only documents | [`files`](./context-variables.md#files) | - | Bool |
45-
| [`allImages`](#allimages)<br />Checks the list includes only images | [`files`](./context-variables.md#files) | - | Bool |
46-
| [`allTests`](#alltests)<br />Checks the list includes only tests | [`files`](./context-variables.md#files) | - | Bool |
47-
| [`codeExperts`](#codeexperts)<br />Get list of contributors based on expert reviewer model results | [`repo`](./context-variables.md#repo) | `gt`, `lt` | [String] |
48-
| [`decode`](#decode)<br />Decode Base64 encoded string into an object | String (Base64 encoded) | - | Object |
49-
| [`encode`](#encode)<br />Encode data into Base64 encoded string | Object | - | String (Base64 encoded) |
50-
| [`estimatedReviewTime`](#estimatedreviewtime)<br />Estimated review time in minutes | [`branch`](./context-variables.md#branch) | - | Integer |
51-
| [`extensions`](#extensions)<br />Lists all the unique file extensions | [String] | - | [String] |
52-
| [`extractJitFindings`](#extractjitfindings) :fontawesome-brands-github: <br />Get an object with a summary of the findings found by the Jit scan | [`pr`](./context-variables.md#pr) | - | Object |
53-
| [`extractSonarFindings`](#extractsonarfindings) :fontawesome-brands-github: <br />Get an object with a summary of the findings found by the SonarCloud scan | [`pr`](./context-variables.md#pr) | - | Object |
54-
| [`explainRankByGitBlame`](#explainrankbygitblame)<br />Short markdown text explaining rankByGitBlame results | [`repo`](./context-variables.md#repo) | `gt`, `lt` | [String] |
55-
| [`isFirstCommit`](#isfirstcommit)<br />Checks if its the author first commit in the repo | [`repo.contributors`](./context-variables.md#repo) | String | Bool |
56-
| [`isFormattingChange`](#isformattingchange)<br />Checks that only formatting changed | [[`FileDiff` ](./context-variables.md#filediff-structure)] | - | Bool |
57-
| [`mapToEnum`](#maptoenum)<br />return the enum value matches to the input key | String | Enum object | Object |
58-
| [`matchDiffLines`](#matchdifflines)<br />Match every line in diff | [[`FileDiff` ](./context-variables.md#filediff-structure)] | `regex`, `ignoreWhiteSpaces` | [Bool] |
59-
| [`rankByGitActivity`](#rankbygitactivity)<br />Get list of contributors based on `git-commit` activity | [`repo`](./context-variables.md#repo) | `gt`, `lt` | [String] |
60-
| [`rankByGitBlame`](#rankbygitblame)<br />Get list of contributors based on `git-blame` results | [`repo`](./context-variables.md#repo) | `gt`, `lt` | [String] |
61-
42+
| Function | Input | Args | Output |
43+
| ----------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------- | -------------------------------------------------- | ----------------------- |
44+
| [`allDocs`](#alldocs)<br />Checks the list includes only documents | [`files`](./context-variables.md#files) | - | Bool |
45+
| [`allImages`](#allimages)<br />Checks the list includes only images | [`files`](./context-variables.md#files) | - | Bool |
46+
| [`allTests`](#alltests)<br />Checks the list includes only tests | [`files`](./context-variables.md#files) | - | Bool |
47+
| [`codeExperts`](#codeexperts)<br />Get list of contributors based on expert reviewer model results | [`repo`](./context-variables.md#repo) | `gt`, `lt` | [String] |
48+
| [`decode`](#decode)<br />Decode Base64 encoded string into an object | String (Base64 encoded) | - | Object |
49+
| [`encode`](#encode)<br />Encode data into Base64 encoded string | Object | - | String (Base64 encoded) |
50+
| [`estimatedReviewTime`](#estimatedreviewtime)<br />Estimated review time in minutes | [`branch`](./context-variables.md#branch) | - | Integer |
51+
| [`extensions`](#extensions)<br />Lists all the unique file extensions | [String] | - | [String] |
52+
| [`extractJitFindings`](#extractjitfindings) :fontawesome-brands-github: <br />Get an object with a summary of the findings found by the Jit scan | [`pr`](./context-variables.md#pr) | - | Object |
53+
| [`extractSonarFindings`](#extractsonarfindings) :fontawesome-brands-github: <br />Get an object with a summary of the findings found by the SonarCloud scan | [`pr`](./context-variables.md#pr) | - | Object |
54+
| [`explainRankByGitBlame`](#explainrankbygitblame)<br />Short markdown text explaining rankByGitBlame results | [`repo`](./context-variables.md#repo) | `gt`, `lt` | [String] |
55+
| [`isFirstCommit`](#isfirstcommit)<br />Checks if its the author first commit in the repo | [`repo.contributors`](./context-variables.md#repo) | String | Bool |
56+
| [`isFormattingChange`](#isformattingchange)<br />Checks that only formatting changed | [[`FileDiff` ](./context-variables.md#filediff-structure)] | - | Bool |
57+
| [`mapToEnum`](#maptoenum)<br />return the enum value matches to the input key | String | Enum object | Object |
58+
| [`matchDiffLines`](#matchdifflines)<br />Match every line in diff | [[`FileDiff` ](./context-variables.md#filediff-structure)] | `regex`, `ignoreWhiteSpaces` | [Bool] |
59+
| [`rankByGitActivity`](#rankbygitactivity)<br />Get list of contributors based on `git-commit` activity | [`repo`](./context-variables.md#repo) | `gt`, `lt` | [String] |
60+
| [`rankByGitBlame`](#rankbygitblame)<br />Get list of contributors based on `git-blame` results | [`repo`](./context-variables.md#repo) | `gt`, `lt` | [String] |
61+
| [`readFile`](#readfile)<br />Reads the contents of a file from the current branch or "cm" folder | String - The file path | String (optional) - the file type. `txt` or `json` | String |
6262
</div>
6363

6464
### Named arguments
@@ -870,25 +870,6 @@ Check if the branch author is a rookie
870870
active_coders: {{ repo | rankByGitActivity(gt=50, weeks=12) }}
871871
```
872872

873-
#### `readFile`
874-
875-
Reads the contents of a file from the current branch or the "cm" folder and returns it as a string. This function only allows reading files from the "repo" and "cm" directories for security reasons.
876-
877-
<div class="filter-details" markdown=1>
878-
879-
| Argument | Usage | Type | Description |
880-
| -------- | ---------|--------|------------------------------------------------ |
881-
| - | Input | String | The path to the file relative to the "repo" or "cm" directory |
882-
| - | Output | String | The contents of the file as a string |
883-
884-
</div>
885-
886-
For example, to read a file named `config.yaml` from the "cm" directory:
887-
888-
```yaml+jinja
889-
{{ "cm/config.yaml" | readFile }}
890-
```
891-
892873
#### `rankByGitBlame`
893874

894875
Get list of contributors based on `git-blame` results
@@ -930,4 +911,23 @@ Check if the branch author is a rookie
930911

931912
```yaml+jinja
932913
is_rookie: {{ repo | rankByGitBlame(lt=15) | match(term=branch.author) | some }}
933-
```
914+
```
915+
916+
#### `readFile`
917+
918+
Reads the contents of a file from the current branch or the "cm" folder and returns it as a string. This function only allows reading files from the "repo" and "cm" directories for security reasons.
919+
920+
<div class="filter-details" markdown=1>
921+
922+
| Argument | Usage | Type | Description |
923+
| -------- | ------ | ------ | ------------------------------------------------------------------- |
924+
| - | Input | String | The path to the file relative to the "repo" or "cm" directory |
925+
| type | Input | String | Optional. `txt` by default. The output type - either`txt` or `json` |
926+
| - | Output | String | The contents of the file as a string |
927+
</div>
928+
929+
For example, to read a file named `config.yaml` from the "cm" directory:
930+
931+
```yaml+jinja
932+
{{ "cm/config.yaml" | readFile }}
933+
```

0 commit comments

Comments
 (0)