๐Ÿคซ ETC

[Github] Github Newline + IntelliJ์—์„œ ์˜ต์…˜ ์„ค์ •

kekeyo 2025. 6. 18. 13:10
728x90

Github์—์„œ์˜ ์˜ค๋ฅ˜

: no newline at a end of file

ํŒŒ์ผ ์‹คํ–‰ ๋“ฑ์—๋Š” ๋ฌธ์ œ๊ฐ€ ์—†๋Š”๋ฐ ์™œ ์ด๋Ÿฐ ์˜ค๋ฅ˜๋ฅผ ํ‘œ์‹œํ•ด์ฃผ๋Š” ๊ฒƒ์ผ๊นŒ?

: POSIX๋ฅผ ๋งŒ์กฑ์‹œํ‚ค๊ธฐ ์œ„ํ•ด์„œ

POSIX์—์„œ ๋ฌธ์ œ๊ฐ€ ๋˜๋Š” ์ด์œ ?

POSIX(Portable Operating System Interface) ํ‘œ์ค€์— ๋”ฐ๋ฅด๋ฉด:

"A text file shall end with a newline character."

 

์ฆ‰, POSIX์—์„œ ํ…์ŠคํŠธ ํŒŒ์ผ์€ ๋งˆ์ง€๋ง‰ ์ค„๋„ ์ค„๋ฐ”๊ฟˆ์œผ๋กœ ๋๋‚˜์•ผ ํ•œ๋‹ค๋Š” ๋ช…ํ™•ํ•œ ๊ทœ์น™์ด ์žˆ์Œ

  • ํŒŒ์ดํ”„/๋ฆฌ๋‹ค์ด๋ ‰์…˜ ์ฒ˜๋ฆฌ ๋ฌธ์ œ
    • POSIX ํ™˜๊ฒฝ์—์„œ๋Š” ์œ ๋‹‰์Šค ์ฒ ํ•™์— ๋”ฐ๋ผ ์—ฌ๋Ÿฌ ๋ช…๋ น์–ด๋ฅผ ํŒŒ์ดํ”„๋กœ ์—ฐ๊ฒฐํ•ด์„œ ์ฒ˜๋ฆฌํ•˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ๋งŽ์Œ.
    • ์ด๋•Œ ์ค„ ๋‹จ์œ„๋กœ ์ž…๋ ฅ์„ ๋ฐ›๋Š”๋ฐ ๋งˆ์ง€๋ง‰ ์ค„์— newline์ด ์—†์œผ๋ฉด ๋งˆ์ง€๋ง‰ ์ค„์ด "์™„์ „ํ•œ ํ•œ ์ค„"๋กœ ์ธ์‹๋˜์ง€ ์•Š์„ ์ˆ˜ ์žˆ์Œ.
  • diff/patch ์ ์šฉ ์˜ค๋ฅ˜ ๊ฐ€๋Šฅ์„ฑ
    • diff/patch ์œ ํ‹ธ๋ฆฌํ‹ฐ๋Š” POSIX ๊ธฐ๋ฐ˜์œผ๋กœ ๋™์ž‘ํ•˜๋ฉฐ ์ค„ ๋‹จ์œ„๋กœ ํŒจ์น˜๋ฅผ ์ƒ์„ฑ/์ ์šฉ.
    • newline์ด ์—†์œผ๋ฉด ํŒจ์น˜ ์ ์šฉ ์‹œ ์˜ค๋ฅ˜ ๋˜๋Š” ์˜ˆ๊ธฐ์น˜ ์•Š์€ ๊ฒฐ๊ณผ ๋ฐœ์ƒ ๊ฐ€๋Šฅ์„ฑ ์žˆ์Œ.
  • ์ •๋ ฌ·ํŒŒ์‹ฑ ํˆด๋“ค ๋™์ž‘ ๋ถˆ์•ˆ์ •
    • sort, awk, sed ๋“ฑ POSIX ๋„๊ตฌ๋“ค์ด "ํ•œ ์ค„์ด ์ค„๋ฐ”๊ฟˆ์œผ๋กœ ๋๋‚œ๋‹ค"๋Š” ์ „์ œ๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ์Œ.

ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•

1. IntelliJ ์„ค์ •์œผ๋กœ ํ•ด๊ฒฐํ•˜๊ธฐ

Settings > General > On Save ์œผ๋กœ ์ด๋™ํ•ด์„œ

Ensure every saved file ends with a line break์— ์ฒดํฌ ํ‘œ์‹œ๋ฅผ ํ•˜๋ฉด ๋œ๋‹ค.

2. .editorconfig  ํŒŒ์ผ ์ด์šฉ

.editorconfig: ์ฝ”๋“œ๋ฒ ์ด์Šค์—์„œ ์ž‘๋™ํ•˜๋Š” ๋ชจ๋“  ์‚ฌ์šฉ์ž์—๊ฒŒ ์ผ๊ด€๋œ ์ฝ”๋”ฉ ์Šคํƒ€์ผ์„ ์ ์šฉ ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ•˜๋Š” ํŒŒ์ผ

  • IDE์—์„œ์˜ ์„ค์ •๋ณด๋‹ค editorconfig ํŒŒ์ผ์ด ์šฐ์„ ๋จ
  • ๋ฃจํŠธ ๊ฒฝ๋กœ์— ๋„ฃ์œผ๋ฉด ์ฝ”๋“œ ์ž‘์„ฑ ์‹œ ์ ์šฉ๋จ
root = true

[*]
# [encoding-utf8]
charset = utf-8

# [newline-lf]
end_of_line = lf

# [newline-eof]
insert_final_newline = true

[*.bat]
end_of_line = crlf

[*.java]
# [indentation-tab]
indent_style = tab

# [4-spaces-tab]
indent_size = 4
tab_width = 4

# [no-trailing-spaces]
trim_trailing_whitespace = true

[line-length-120]
max_line_length = 120

https://editorconfig.org/

 

EditorConfig

What is EditorConfig? EditorConfig helps maintain consistent coding styles for multiple developers working on the same project across various editors and IDEs. The EditorConfig project consists of a file format for defining coding styles and a collection o

editorconfig.org

 

 

 

728x90