Skip to content

Commit

Permalink
Release v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthri committed Jul 22, 2023
2 parents 254c50b + 18e2092 commit 0b77e94
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 54 deletions.
13 changes: 5 additions & 8 deletions .github/workflows/check-eol.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,16 @@ jobs:
ref: ${{ inputs.checkout-ref }}

- name: Check End-of-Line Sequence
env:
DEFAULT_EOL: ${{ inputs.default-eol }}
run: |
exit_code=0
while IFS= read line; do
if [[ $line =~ ^i/([^ ]*)\ +w/([^ ]*)\ +attr/([^[:space:]]+( eol=([[:alpha:]]+))?)?\ +$'\t'(.+)$ ]] ; then
if [[ $line =~ ^i/([^ ]*)\ +w/[^\ ]*\ +attr/[^$'\t']+$'\t'(.+)$ ]] ; then
index_eol=${BASH_REMATCH[1]}
working_tree_eol=${BASH_REMATCH[2]}
expected_eol=${BASH_REMATCH[5]:-${{ inputs.default-eol }}}
if { [ "$index_eol" == "lf" ] || [ "$index_eol" == "crlf" ] || [ "$index_eol" == "mixed" ] ; } && [ "$index_eol" != "$expected_eol" ] ; then
echo "${BASH_REMATCH[6]}:"$'\t'"End-of-line sequence in index($index_eol) does not match expected end-of-line sequence $expected_eol."
exit_code=1
elif { [ "$working_tree_eol" == "lf" ] || [ "$working_tree_eol" == "crlf" ] || [ "$working_tree_eol" == "mixed" ] ; } && [ "$working_tree_eol" != "$expected_eol" ] ; then
echo "${BASH_REMATCH[6]}:"$'\t'"End-of-line sequence in working tree($working_tree_eol) does not match expected end-of-line sequence $expected_eol."
if [ "$index_eol" != $DEFAULT_EOL ] ; then
echo "${BASH_REMATCH[2]}:"$'\t'"End-of-line sequence in index($index_eol) must be LF."
exit_code=1
fi
else
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
## Usage

### Default End-of-Line Sequence
The workflow uses `LF` as the fallback end-of-line sequence. The default end-of-line sequence can be configured either through [`.gitattributes`](https://www.git-scm.com/docs/gitattributes) or through the parameter `default-eol`. The following example sets the fallback end-of-line sequence to `CRLF`.
The workflow enforces `LF` for all files in the index. `autocrlf=true` modifies files in the working tree rather than the index and thus does not affect the workflow. The following example configures the workflow to enforce `CRLF` instead.
```yml
jobs:
check-eol:
Expand Down
49 changes: 8 additions & 41 deletions docs/Test_List.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,61 +5,28 @@ A list of steps for testing the workflow's features.

### Steps
1. Create the following files,
- `lf-lf.txt` - A file containing one LF.
- `lf-crlf.txt` - A file containing one CRLF.
- `lf-mixed.txt` - A file containing one LF and one CRLF.
- `crlf-lf.txt` - A file containing one LF.
- `crlf-crlf.txt` - A file containing one CRLF.
- `crlf-mixed.txt` - A file containing one LF and one CRLF.
- `lf.txt` - A file containing one LF.
- `crlf.txt` - A file containing one CRLF.
- `mixed.txt` - A file containing one LF and one CRLF.
1. Create or copy a binary file, such as an image or an archive.
1. Run the command `git config core.autocrlf false`
1. Create a file named `.gitattributes` with the following contents,
```ini
lf-*.txt text eol=lf
crlf-*.txt text eol=crlf
```
1. All other files created such as `.gitattributes` and workflow files must be using the LF end-of-line sequence.
1. All other files created such as workflow files must be using the LF end-of-line sequence.
1. Commit and push to GitHub.

### Outputs
1. Workflow triggers.
1. Workflow fails.
1. The workflow should flag the following files,
- `lf-crlf.txt`.
- `lf-mixed.txt`.
- `crlf-lf.txt`.
- `crlf-mixed.txt`.
- `crlf.txt`.
- `mixed.txt`.
1. The workflow should not flag the following files,
- `lf-lf.txt`.
- `crlf-crlf.txt`.
- `lf.txt`.
- The binary file.

## Action respects `.gitattributes`

### Steps
1. Replace the contents of the file named `.gitattributes` with the following,
```ini
*-lf.txt text eol=lf
*-crlf.txt text eol=crlf
```
1. Remove the files ending in `mixed`.
1. Commit and push to GitHub.

### Outputs
1. Workflow triggers.
1. Workflow succeeds.

## Action succeeds when non-compliant files are fixed

### Steps
1. Replace the contents of the file named `.gitattributes` with the following,
```ini
lf-*.txt text eol=lf
crlf-*.txt text eol=crlf
```
1. Restore the files ending in `mixed`.
1. Replace all non-LF end-of-line sequences with LF in files starting with `lf-*`.
1. Replace all non-CRLF end-of-line sequences with CRLF in files starting with `crlf-*`.
1. Replace all non-LF end-of-line sequences with LF in flagged files.

### Outputs
1. Workflow triggers.
Expand Down
2 changes: 0 additions & 2 deletions test/respects_gitattributes/.gitattributes

This file was deleted.

1 change: 0 additions & 1 deletion test/respects_gitattributes/crlf.txt

This file was deleted.

1 change: 0 additions & 1 deletion test/respects_gitattributes/lf.txt

This file was deleted.

0 comments on commit 0b77e94

Please sign in to comment.