Skip to content

Commit

Permalink
Merge pull request #572 from linear-b/decode-and-encode
Browse files Browse the repository at this point in the history
Decode and encode
  • Loading branch information
PavelLinearB committed Sep 2, 2024
2 parents 2201cf3 + 6f08e42 commit 5fa2be4
Showing 1 changed file with 51 additions and 17 deletions.
68 changes: 51 additions & 17 deletions docs/filter-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,25 @@ The following functions are supported in addition to the built-in functions prov

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

| Function | Input | Args | Output |
| --------------- | ------- | ---- | ---- |
| [`allDocs`](#alldocs)<br />Checks the list includes only documents | [`files`](./context-variables.md#files) | - | Bool |
| [`allImages`](#allimages)<br />Checks the list includes only images | [`files`](./context-variables.md#files) | - | Bool |
| [`allTests`](#alltests)<br />Checks the list includes only tests | [`files`](./context-variables.md#files) | - | Bool |
| [`codeExperts`](#codeexperts)<br />Get list of contributors based on expert reviewer model results| [`repo`](./context-variables.md#repo) | `gt`, `lt` | [String] |
| [`estimatedReviewTime`](#estimatedreviewtime)<br />Estimated review time in minutes | [`branch`](./context-variables.md#branch)| - | Integer |
| [`extensions`](#extensions)<br />Lists all the unique file extensions | [String] | - | [String] |
| [`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 |
| [`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 |
| [`explainRankByGitBlame`](#explainrankbygitblame)<br />Short markdown text explaining rankByGitBlame results | [`repo`](./context-variables.md#repo) | `gt`, `lt` | [String] |
| [`isFirstCommit`](#isfirstcommit)<br />Checks if its the author first commit in the repo | [`repo.contributors`](./context-variables.md#repo) | String | Bool |
| [`isFormattingChange`](#isformattingchange)<br />Checks that only formatting changed | [[`FileDiff` ](./context-variables.md#filediff-structure)] | - | Bool |
| [`mapToEnum`](#maptoenum)<br />return the enum value matches to the input key | String | Enum object | Object |
| [`matchDiffLines`](#matchdifflines)<br />Match every line in diff | [[`FileDiff` ](./context-variables.md#filediff-structure)] | `regex`, `ignoreWhiteSpaces` | [Bool] |
| [`rankByGitActivity`](#rankbygitactivity)<br />Get list of contributors based on `git-commit` activity | [`repo`](./context-variables.md#repo) | `gt`, `lt` | [String] |
| [`rankByGitBlame`](#rankbygitblame)<br />Get list of contributors based on `git-blame` results| [`repo`](./context-variables.md#repo) | `gt`, `lt` | [String] |
| Function | Input | Args | Output |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------- | ----------------------- |
| [`allDocs`](#alldocs)<br />Checks the list includes only documents | [`files`](./context-variables.md#files) | - | Bool |
| [`allImages`](#allimages)<br />Checks the list includes only images | [`files`](./context-variables.md#files) | - | Bool |
| [`allTests`](#alltests)<br />Checks the list includes only tests | [`files`](./context-variables.md#files) | - | Bool |
| [`codeExperts`](#codeexperts)<br />Get list of contributors based on expert reviewer model results | [`repo`](./context-variables.md#repo) | `gt`, `lt` | [String] |
| [`decode`](#decode)<br />Decode Base64 encoded string into an object | String (Base64 encoded) | - | Object |
| [`encode`](#encode)<br />Encode data into Base64 encoded string | Object | - | String (Base64 encoded) |
| [`estimatedReviewTime`](#estimatedreviewtime)<br />Estimated review time in minutes | [`branch`](./context-variables.md#branch) | - | Integer |
| [`extensions`](#extensions)<br />Lists all the unique file extensions | [String] | - | [String] |
| [`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 |
| [`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 |
| [`explainRankByGitBlame`](#explainrankbygitblame)<br />Short markdown text explaining rankByGitBlame results | [`repo`](./context-variables.md#repo) | `gt`, `lt` | [String] |
| [`isFirstCommit`](#isfirstcommit)<br />Checks if its the author first commit in the repo | [`repo.contributors`](./context-variables.md#repo) | String | Bool |
| [`isFormattingChange`](#isformattingchange)<br />Checks that only formatting changed | [[`FileDiff` ](./context-variables.md#filediff-structure)] | - | Bool |
| [`mapToEnum`](#maptoenum)<br />return the enum value matches to the input key | String | Enum object | Object |
| [`matchDiffLines`](#matchdifflines)<br />Match every line in diff | [[`FileDiff` ](./context-variables.md#filediff-structure)] | `regex`, `ignoreWhiteSpaces` | [Bool] |
| [`rankByGitActivity`](#rankbygitactivity)<br />Get list of contributors based on `git-commit` activity | [`repo`](./context-variables.md#repo) | `gt`, `lt` | [String] |
| [`rankByGitBlame`](#rankbygitblame)<br />Get list of contributors based on `git-blame` results | [`repo`](./context-variables.md#repo) | `gt`, `lt` | [String] |

</div>

Expand Down Expand Up @@ -406,6 +408,38 @@ automations:
reviewers: {{ repo | codeExperts(gt=10) }}
```

#### `decode`

Decode Base64 encoded string into an object. Encoded strings are formatted: `"base64: <encoded_string>"`
<div class="filter-details" markdown=1>

| Argument | Usage | Type | Description |
| -------- | ------ | ------ | ------------------------------------------- |
| - | Input | String | Base64 encoded string prefixed `"Base64: "` |
| - | Output | Object | Decoded objet |

</div>

```yaml+jinja
{{ "base64: SGVsbG8gV29ybGQ=" | decode }} # Output: "Hello World"
```

#### `encode`

Encode data into Base64 encoded string. When an encoded string is passed as input for [`add-comment`](./automation-actions.md#add-comment), the action automatically detects and decodes it.
<div class="filter-details" markdown=1>

| Argument | Usage | Type | Description |
| -------- | ------ | ------------ | ----------------------------------- |
| - | Input | Object | The input object to encode |
| - | Output | String (Base64) | Base64 encoding of the object |

</div>

```yaml+jinja
{{ "Hello World" | encode }} # Output: "base64: SGVsbG8gV29ybGQ="
```

#### `estimatedReviewTime`

Returns the estimated review time in minutes based on statistical model.
Expand Down

0 comments on commit 5fa2be4

Please sign in to comment.