[pacman-dev,v2] srcinfo.sh: remove trailing newline

Message ID 20200611021407.68993-1-liu.denton@gmail.com
State Superseded, archived
Headers show
Series [pacman-dev,v2] srcinfo.sh: remove trailing newline | expand

Commit Message

Denton Liu June 11, 2020, 2:14 a.m. UTC
When a .SRCINFO file is generated via `makepkg --printsrcinfo`, each
section is concluded with an empty line. This means that at the end of
the file, an empty line remains. This is considered a trailing
whitespace error. In fact, `git diff --check` will about this saying
"new blank line at EOF."

Instead of closing each section off with an empty line, use the empty
line to separate sections, omitting the empty line at the end of the
file.
---
 scripts/libmakepkg/srcinfo.sh.in | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Denton Liu June 11, 2020, 2:19 a.m. UTC | #1
Sorry, small typo:

On Wed, Jun 10, 2020 at 10:14:07PM -0400, Denton Liu wrote:
> When a .SRCINFO file is generated via `makepkg --printsrcinfo`, each
> section is concluded with an empty line. This means that at the end of
> the file, an empty line remains. This is considered a trailing
> whitespace error. In fact, `git diff --check` will about this saying

s/will/will warn/

> "new blank line at EOF."
> 
> Instead of closing each section off with an empty line, use the empty
> line to separate sections, omitting the empty line at the end of the
> file.

Patch

diff --git a/scripts/libmakepkg/srcinfo.sh.in b/scripts/libmakepkg/srcinfo.sh.in
index 6e783279..d1e39f7d 100644
--- a/scripts/libmakepkg/srcinfo.sh.in
+++ b/scripts/libmakepkg/srcinfo.sh.in
@@ -30,7 +30,7 @@  srcinfo_open_section() {
 	printf '%s = %s\n' "$1" "$2"
 }
 
-srcinfo_close_section() {
+srcinfo_separate_section() {
 	echo
 }
 
@@ -94,7 +94,6 @@  srcinfo_write_global() {
 
 	srcinfo_open_section 'pkgbase' "${pkgbase:-$pkgname}"
 	srcinfo_write_section_details ''
-	srcinfo_close_section
 }
 
 srcinfo_write_package() {
@@ -104,7 +103,6 @@  srcinfo_write_package() {
 
 	srcinfo_open_section 'pkgname' "$1"
 	srcinfo_write_section_details "$1"
-	srcinfo_close_section
 }
 
 write_srcinfo_header() {
@@ -118,6 +116,7 @@  write_srcinfo_content() {
 	srcinfo_write_global
 
 	for pkg in "${pkgname[@]}"; do
+		srcinfo_separate_section
 		srcinfo_write_package "$pkg"
 	done
 }