forked from ansible-collections/community.windows
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable keeping last empty line for win_lineinfile (ansible-collection…
…s#219) * Keep last empty line for win_lineinfile Ensure that an empty last line is still be present in the output file when changed. * Keep whitespace consistent * Added changelog fragment Co-authored-by: Daniel Blixt <daniel.blixt.2@volvocars.com> Co-authored-by: Jordan Borean <jborean93@gmail.com>
- Loading branch information
1 parent
1120f0c
commit 0cc0319
Showing
39 changed files
with
332 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bugfixes: | ||
- win_lineinfile - Avoid stripping the newline at the end of a file - https://github.com/ansible-collections/community.windows/pull/219 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
tests/integration/targets/win_lineinfile/files/expectations/.gitattributes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
*.text text eol=LF | ||
*.txt text eol=CRLF | ||
*.txt16 text working-tree-encoding=UTF-16 eol=CRLF | ||
*.txt32 text working-tree-encoding=UTF-32 eol=CRLF |
6 changes: 6 additions & 0 deletions
6
tests/integration/targets/win_lineinfile/files/expectations/01_new_line_at_bof.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
New line at the beginning | ||
This is line 1 | ||
This is line 2 | ||
REF this is a line for backrefs REF | ||
This is line 4 | ||
This is line 5 |
7 changes: 7 additions & 0 deletions
7
tests/integration/targets/win_lineinfile/files/expectations/02_new_line_at_eof.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
New line at the beginning | ||
This is line 1 | ||
This is line 2 | ||
REF this is a line for backrefs REF | ||
This is line 4 | ||
This is line 5 | ||
New line at the end |
8 changes: 8 additions & 0 deletions
8
tests/integration/targets/win_lineinfile/files/expectations/03_new_line_after_1.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
New line at the beginning | ||
This is line 1 | ||
New line after line 1 | ||
This is line 2 | ||
REF this is a line for backrefs REF | ||
This is line 4 | ||
This is line 5 | ||
New line at the end |
9 changes: 9 additions & 0 deletions
9
tests/integration/targets/win_lineinfile/files/expectations/04_new_line_before_5.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
New line at the beginning | ||
This is line 1 | ||
New line after line 1 | ||
This is line 2 | ||
REF this is a line for backrefs REF | ||
This is line 4 | ||
New line before line 5 | ||
This is line 5 | ||
New line at the end |
9 changes: 9 additions & 0 deletions
9
tests/integration/targets/win_lineinfile/files/expectations/05_new_line_at_REF.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
New line at the beginning | ||
This is line 1 | ||
New line after line 1 | ||
This is line 2 | ||
This is line 3 | ||
This is line 4 | ||
New line before line 5 | ||
This is line 5 | ||
New line at the end |
8 changes: 8 additions & 0 deletions
8
tests/integration/targets/win_lineinfile/files/expectations/06_remove_middle_line.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
New line at the beginning | ||
This is line 1 | ||
New line after line 1 | ||
This is line 2 | ||
This is line 4 | ||
New line before line 5 | ||
This is line 5 | ||
New line at the end |
7 changes: 7 additions & 0 deletions
7
tests/integration/targets/win_lineinfile/files/expectations/07_remove_line_5.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
New line at the beginning | ||
This is line 1 | ||
New line after line 1 | ||
This is line 2 | ||
This is line 4 | ||
New line before line 5 | ||
New line at the end |
7 changes: 7 additions & 0 deletions
7
tests/integration/targets/win_lineinfile/files/expectations/08_no_expected_change.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
New line at the beginning | ||
This is line 1 | ||
New line after line 1 | ||
This is line 2 | ||
This is line 4 | ||
New line before line 5 | ||
New line at the end |
1 change: 1 addition & 0 deletions
1
tests/integration/targets/win_lineinfile/files/expectations/09_new_file.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This is a new file |
3 changes: 3 additions & 0 deletions
3
tests/integration/targets/win_lineinfile/files/expectations/10_no_eof_new_at_eof.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
This is line 1 | ||
This is line 2 | ||
New line at the end |
9 changes: 9 additions & 0 deletions
9
tests/integration/targets/win_lineinfile/files/expectations/11_multiline_at_eof.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
New line at the beginning | ||
This is line 1 | ||
New line after line 1 | ||
This is line 2 | ||
This is line 4 | ||
New line before line 5 | ||
New line at the end | ||
This is a line | ||
with newline character |
1 change: 1 addition & 0 deletions
1
tests/integration/targets/win_lineinfile/files/expectations/12_empty_file_add_at_eof.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
New line at the end |
9 changes: 9 additions & 0 deletions
9
tests/integration/targets/win_lineinfile/files/expectations/13_new_4_with_backref.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
New line at the beginning | ||
This is line 1 | ||
New line after line 1 | ||
This is line 2 | ||
New line 4 created with the backref | ||
New line before line 5 | ||
New line at the end | ||
This is a line | ||
with newline character |
3 changes: 3 additions & 0 deletions
3
tests/integration/targets/win_lineinfile/files/expectations/14_quoting_code.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
var dotenv = require('dotenv'); | ||
dotenv.load(); | ||
'foo' |
4 changes: 4 additions & 0 deletions
4
tests/integration/targets/win_lineinfile/files/expectations/15_single_quote.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
var dotenv = require('dotenv'); | ||
dotenv.load(); | ||
'foo' | ||
import g' |
5 changes: 5 additions & 0 deletions
5
tests/integration/targets/win_lineinfile/files/expectations/16_multiple_quotes.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
var dotenv = require('dotenv'); | ||
dotenv.load(); | ||
'foo' | ||
import g' | ||
"quote" and "unquote" |
1 change: 1 addition & 0 deletions
1
tests/integration/targets/win_lineinfile/files/expectations/17_new_file_win.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This is a new file |
2 changes: 2 additions & 0 deletions
2
tests/integration/targets/win_lineinfile/files/expectations/18_sep_win.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
This is a new file | ||
This is the last line |
1 change: 1 addition & 0 deletions
1
tests/integration/targets/win_lineinfile/files/expectations/19_new_file_unix.text
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This is a new file |
2 changes: 2 additions & 0 deletions
2
tests/integration/targets/win_lineinfile/files/expectations/20_sep_unix.text
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
This is a new file | ||
This is the last line |
1 change: 1 addition & 0 deletions
1
tests/integration/targets/win_lineinfile/files/expectations/21_utf8_no_bom.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This is a new utf-8 file |
2 changes: 2 additions & 0 deletions
2
tests/integration/targets/win_lineinfile/files/expectations/22_utf8_no_bom_line_added.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
This is a new utf-8 file | ||
This is the last line |
1 change: 1 addition & 0 deletions
1
tests/integration/targets/win_lineinfile/files/expectations/23_utf8_bom.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This is a new utf-8 file |
2 changes: 2 additions & 0 deletions
2
tests/integration/targets/win_lineinfile/files/expectations/24_utf8_bom_line_added.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
This is a new utf-8 file | ||
This is the last line |
1 change: 1 addition & 0 deletions
1
tests/integration/targets/win_lineinfile/files/expectations/25_utf16.txt16
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This is a new utf-16 file |
2 changes: 2 additions & 0 deletions
2
tests/integration/targets/win_lineinfile/files/expectations/26_utf16_line_added.txt16
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
This is a new utf-16 file | ||
This is the last line |
1 change: 1 addition & 0 deletions
1
tests/integration/targets/win_lineinfile/files/expectations/27_utf32.txt32
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This is a new utf-32 file |
2 changes: 2 additions & 0 deletions
2
tests/integration/targets/win_lineinfile/files/expectations/28_utf32_line_added.txt32
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
This is a new utf-32 file | ||
This is the last line |
1 change: 1 addition & 0 deletions
1
tests/integration/targets/win_lineinfile/files/expectations/29_no_linebreak.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
c:\return\new |
3 changes: 3 additions & 0 deletions
3
tests/integration/targets/win_lineinfile/files/expectations/30_linebreaks_checksum_bad.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
c:\return\new | ||
c:eturn | ||
ew | ||
|
6 changes: 6 additions & 0 deletions
6
tests/integration/targets/win_lineinfile/files/expectations/31_relative_path.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
New line at the beginning | ||
This is line 1 | ||
This is line 2 | ||
REF this is a line for backrefs REF | ||
This is line 4 | ||
This is line 5 |
36 changes: 36 additions & 0 deletions
36
tests/integration/targets/win_lineinfile/files/expectations/99_README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
***WIN LINEINFILE Expectations*** | ||
|
||
This folder contains expected files as the tests in this playbook executes on the | ||
files in 'files'. | ||
|
||
To get the checksum as would win_stat in the tests, go to this folder in powershell and | ||
execute | ||
|
||
```powershell | ||
Get-ChildItem | ForEach-Object { | ||
$fp = [System.IO.File]::Open("$pwd/$($_.Name)", [System.IO.Filemode]::Open, [System.IO.FileAccess]::Read, [System.IO.FileShare]::ReadWrite) | ||
Write-Output $_.Name | ||
try { | ||
[System.BitConverter]::ToString($sp.ComputeHash($fp)).Replace("-", "").ToLower() | ||
} finally { | ||
$fp.Dispose() | ||
} | ||
Write-Output "" | ||
} | ||
``` | ||
|
||
There is one exception right now: 30_linebreaks_checksum_bad.txt which requires mixed line endings that | ||
git cannot handle without turning the file binary. The file should read | ||
|
||
``` | ||
c:\return\newCRLF | ||
c:CR | ||
eturnLF | ||
ew | ||
``` | ||
where CR and LF denote carriage return (\r) and line feed (\n) respectively, to get the correct checksum. | ||
|
||
Also, the .gitattributes files is important as it assures that the EOL characters | ||
for the files are correct, regardless of environment. The files may be checked out on | ||
linux but the resulting files will be created using windows EOL, and the comparison must | ||
match. |
Oops, something went wrong.