Skip to content

Commit

Permalink
fix: Update bytes_utils.go (#468)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
jackton1 and github-actions[bot] committed May 3, 2023
1 parent 3cc77da commit 8dc1ee9
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 7 deletions.
15 changes: 14 additions & 1 deletion internal/utils/bytes_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,23 @@ func HasBytesInBetween(value, start, end []byte) (found bool, startIndexes []int
endIndex := endLoc[1] + i

if startIndex < endIndex {
// Check if there is a closer end index between the current start and the previously found end index
for j := len(endIndexes) - 1; j >= 0; j-- {
if endIndex < endIndexes[j] && endIndexes[j] < startIndex {
// Use the closer end index instead
endIndex = endIndexes[j]
}
}

startIndexes = append(startIndexes, startIndex)
endIndexes = append(endIndexes, endIndex)

// Move the index to the end of the found end index
i = endIndex - 1
} else {
// Move the index to the end of the found start index
i = startIndex - 1
}
i += endIndex // skip the content between end and next start
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/README-inputColumns.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
| output_dir | string | Directory to store output files. |
| path | string | Specify a relative path under `$GITHUB_WORKSPACE`<br>to locate the repository. |
| quotepath | string | Use non ascii characters to match<br> files and output the filenames completely<br>verbatim by setting this to `false` |
| separator | string | Split character for output strings |
| separator | string | Split character for output strings. |
| sha | string | Specify a different commit SHA used<br>for comparing changes |
| since | string | Get changed files for commits whose<br> timestamp is older than the given<br>time. |
| since_last_remote_commit | string | Use the last commit on the<br> remote branch as the `base_sha`. Defaults<br> to the last non merge commit<br> on the target branch for pull<br> request events and the previous remote<br> commit of the current branch for<br>push events. |
Expand Down
2 changes: 1 addition & 1 deletion test/README-outputColumns.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
| output_dir | string | false | `".github/outputs"` | Directory to store output files. |
| path | string | false | `"."` | Specify a relative path under `$GITHUB_WORKSPACE`<br>to locate the repository. |
| quotepath | string | false | `"true"` | Use non ascii characters to match<br> files and output the filenames completely<br>verbatim by setting this to `false` |
| separator | string | false | `" "` | Split character for output strings |
| separator | string | false | `" "` | Split character for output strings. |
| sha | string | false | | Specify a different commit SHA used<br>for comparing changes |
| since | string | false | | Get changed files for commits whose<br> timestamp is older than the given<br>time. |
| since_last_remote_commit | string | true | `"false"` | Use the last commit on the<br> remote branch as the `base_sha`. Defaults<br> to the last non merge commit<br> on the target branch for pull<br> request events and the previous remote<br> commit of the current branch for<br>push events. |
Expand Down
39 changes: 36 additions & 3 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Test text ## Inputs
| output_dir | string | false | `".github/outputs"` | Directory to store output files. |
| path | string | false | `"."` | Specify a relative path under `$GITHUB_WORKSPACE`<br>to locate the repository. |
| quotepath | string | false | `"true"` | Use non ascii characters to match<br> files and output the filenames completely<br>verbatim by setting this to `false` |
| separator | string | false | `" "` | Split character for output strings |
| separator | string | false | `" "` | Split character for output strings. |
| sha | string | false | | Specify a different commit SHA used<br>for comparing changes |
| since | string | false | | Get changed files for commits whose<br> timestamp is older than the given<br>time. |
| since_last_remote_commit | string | true | `"false"` | Use the last commit on the<br> remote branch as the `base_sha`. Defaults<br> to the last non merge commit<br> on the target branch for pull<br> request events and the previous remote<br> commit of the current branch for<br>push events. |
Expand All @@ -37,7 +37,40 @@ Test text ## Inputs

<!-- AUTO-DOC-INPUT:END -->

------
## Inputs

<!-- AUTO-DOC-INPUT:START - Do not remove or modify this section -->

| INPUT | TYPE | REQUIRED | DEFAULT | DESCRIPTION |
|-----------------------------------|--------|----------|---------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| base_sha | string | false | | Specify a different base commit SHA<br>used for comparing changes |
| diff_relative | string | false | | Exclude changes outside the current directory<br> and show path names relative to<br> it. **NOTE:** This requires you to<br> specify the top level directory via<br>the `path` input. |
| dir_names | string | false | `"false"` | Output unique changed directories instead of<br> filenames. **NOTE:** This returns `.` for<br> changed files located in the root<br>of the project. |
| dir_names_max_depth | string | false | | Maximum depth of directories to output.<br> e.g `test/test1/test2` with max depth of<br>`2` returns `test/test1`. |
| fetch_depth | string | false | `"50"` | Depth of additional branch history fetched.<br> **NOTE**: This can be adjusted to<br>resolve errors with insufficient history. |
| files | string | false | | File and directory patterns to detect<br> changes using only these list of<br> file(s) (Defaults to the entire repo)<br> **NOTE:** Multiline file/directory patterns should not<br>include quotes. |
| files_from_source_file | string | false | | Source file(s) used to populate the<br>`files` input. |
| files_ignore | string | false | | Ignore changes to these file(s) **NOTE:**<br> Multiline file/directory patterns should not include<br>quotes. |
| files_ignore_from_source_file | string | false | | Source file(s) used to populate the<br>`files_ignore` input |
| files_ignore_separator | string | false | `"\n"` | Separator used to split the `files_ignore`<br>input |
| files_separator | string | false | `"\n"` | Separator used to split the `files`<br>input |
| include_all_old_new_renamed_files | string | false | `"false"` | Include `all_old_new_renamed_files` output. Note this can<br>generate a large output See: [#501](https://github.com/tj-actions/changed-files/issues/501). |
| json | string | false | `"false"` | Output list of changed files in<br> a JSON formatted string which can<br>be used for matrix jobs. |
| json_raw_format | string | false | `"false"` | Output list of changed files in<br> a raw format which means that<br> the output will not be surrounded<br> by quotes and special characters will<br>not be escaped. |
| match_directories | string | false | `"true"` | Indicates whether to include match directories |
| old_new_files_separator | string | false | `" "` | Split character for old and new<br>renamed filename pairs. |
| old_new_separator | string | false | `","` | Split character for old and new<br>filename pairs. |
| output_dir | string | false | `".github/outputs"` | Directory to store output files. |
| path | string | false | `"."` | Specify a relative path under `$GITHUB_WORKSPACE`<br>to locate the repository. |
| quotepath | string | false | `"true"` | Use non ascii characters to match<br> files and output the filenames completely<br>verbatim by setting this to `false` |
| separator | string | false | `" "` | Split character for output strings. |
| sha | string | false | | Specify a different commit SHA used<br>for comparing changes |
| since | string | false | | Get changed files for commits whose<br> timestamp is older than the given<br>time. |
| since_last_remote_commit | string | true | `"false"` | Use the last commit on the<br> remote branch as the `base_sha`. Defaults<br> to the last non merge commit<br> on the target branch for pull<br> request events and the previous remote<br> commit of the current branch for<br>push events. |
| until | string | false | | Get changed files for commits whose<br> timestamp is earlier than the given<br>time. |
| write_output_files | string | false | `"false"` | Write outputs to files in the<br>`.github/outputs` folder by default. |

<!-- AUTO-DOC-INPUT:END -->

## Inputs

Expand Down Expand Up @@ -65,7 +98,7 @@ Test text ## Inputs
| output_dir | string | false | `".github/outputs"` | Directory to store output files. |
| path | string | false | `"."` | Specify a relative path under `$GITHUB_WORKSPACE`<br>to locate the repository. |
| quotepath | string | false | `"true"` | Use non ascii characters to match<br> files and output the filenames completely<br>verbatim by setting this to `false` |
| separator | string | false | `" "` | Split character for output strings |
| separator | string | false | `" "` | Split character for output strings. |
| sha | string | false | | Specify a different commit SHA used<br>for comparing changes |
| since | string | false | | Get changed files for commits whose<br> timestamp is older than the given<br>time. |
| since_last_remote_commit | string | true | `"false"` | Use the last commit on the<br> remote branch as the `base_sha`. Defaults<br> to the last non merge commit<br> on the target branch for pull<br> request events and the previous remote<br> commit of the current branch for<br>push events. |
Expand Down
2 changes: 1 addition & 1 deletion test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ author: tj-actions

inputs:
separator:
description: "Split character for output strings"
description: "Split character for output strings."
required: false
default: " "
include_all_old_new_renamed_files:
Expand Down

0 comments on commit 8dc1ee9

Please sign in to comment.