Skip to content

Commit 2259e7f

Browse files
committed
fix: strip trailing whitespaces from gitignore.io responses
gitignore.io sometimes returns files with trailing whitespaces at the end of lines. This causes issues when editors remove the whitespaces on formatting, causing autogenerated parts of .gitignore file to change and fail kraken check.
1 parent 1e4b772 commit 2259e7f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

kraken-build/src/kraken/std/git/gitignore/gitignore_io.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,12 @@ def gitignore_io_fetch(tokens: Sequence[str]) -> str:
6161
url = GITIGNORE_API_URL + ",".join(tokens)
6262
response = http.get(url)
6363
response.raise_for_status()
64-
return response.text.replace("\r\n", "\n")
64+
lines = response.text.replace("\r\n", "\n").split("\n")
65+
# gitignore.io sometimes returns files with trailing whitespaces at the end of lines
66+
# this causes issues when editors remove the whitespaces on formatting, causing autogenerated
67+
# parts of .gitignore file to change and fail kraken check
68+
lines = [line.rstrip() for line in lines]
69+
return '\n'.join(lines)
6570

6671

6772
def gitignore_io_fetch_cached(tokens: Sequence[str], backfill: bool) -> str:

0 commit comments

Comments
 (0)