diff mbox series

[SRU,X/B/F/G/H/U] UBUNTU: [Packaging] insertchanges: avoid double newline

Message ID 20201105161643.1087403-1-cascardo@canonical.com
State New
Headers show
Series [SRU,X/B/F/G/H/U] UBUNTU: [Packaging] insertchanges: avoid double newline | expand

Commit Message

Thadeu Lima de Souza Cascardo Nov. 5, 2020, 4:16 p.m. UTC
When some changes have been already added to the changelog, like when using
insert-ubuntu-changes, and there are no other changes, we end up with two
newlines right after the stanza header.

Add a $skip_newline variable that allows us to skip that extra newline when
there are no other changes.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
---
 debian/scripts/misc/insert-changes.pl | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Andrea Righi Nov. 5, 2020, 4:27 p.m. UTC | #1
On Thu, Nov 05, 2020 at 01:16:43PM -0300, Thadeu Lima de Souza Cascardo wrote:
> When some changes have been already added to the changelog, like when using
> insert-ubuntu-changes, and there are no other changes, we end up with two
> newlines right after the stanza header.
> 
> Add a $skip_newline variable that allows us to skip that extra newline when
> there are no other changes.
> 
> Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>

Minor nitpick below, but overall it looks good to me.

Acked-by: Andrea Righi <andrea.righi@canonical.com>

> ---
>  debian/scripts/misc/insert-changes.pl | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/debian/scripts/misc/insert-changes.pl b/debian/scripts/misc/insert-changes.pl
> index c820597a9fc9..dde210faac34 100755
> --- a/debian/scripts/misc/insert-changes.pl
> +++ b/debian/scripts/misc/insert-changes.pl
> @@ -13,17 +13,26 @@ open(CHANGES, "< $debian/changes") or die "Cannot open new changes";
>  open(NEW, "> $debian/changelog.new") or die "Cannot open new changelog";
>  
>  $printed = 0;
> +my $skip_newline = 0;
>  
>  while (<CHANGELOG>) {
>  	if (/^  CHANGELOG: /) {
>  		next if $printed;
>  
> +		$skip_newline = 1;
>  		while (<CHANGES>) {
> +			$skip_newline = 0;
>  			print NEW;
>  		}
>  
>  		$printed = 1;
>  	} else {
> +		if (/^$/) {
> +			if ($skip_newline == 1) {

Maybe "if (/^$/ && $skip_newline)" would be more compact and still
readable, but it's just a minor nitpick.

> +				$skip_newline = 0;
> +				next;
> +			}
> +		}
>  		print NEW;
>  	}
>  }
> -- 
> 2.27.0
> 
> 
> -- 
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team
Kelsey Skunberg Nov. 6, 2020, 12:02 a.m. UTC | #2
Before applying could we get a BugLink to include?

Otherwise lgtm.

Acked-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>

On 2020-11-05 13:16:43 , Thadeu Lima de Souza Cascardo wrote:
> When some changes have been already added to the changelog, like when using
> insert-ubuntu-changes, and there are no other changes, we end up with two
> newlines right after the stanza header.
> 
> Add a $skip_newline variable that allows us to skip that extra newline when
> there are no other changes.
> 
> Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
> ---
>  debian/scripts/misc/insert-changes.pl | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/debian/scripts/misc/insert-changes.pl b/debian/scripts/misc/insert-changes.pl
> index c820597a9fc9..dde210faac34 100755
> --- a/debian/scripts/misc/insert-changes.pl
> +++ b/debian/scripts/misc/insert-changes.pl
> @@ -13,17 +13,26 @@ open(CHANGES, "< $debian/changes") or die "Cannot open new changes";
>  open(NEW, "> $debian/changelog.new") or die "Cannot open new changelog";
>  
>  $printed = 0;
> +my $skip_newline = 0;
>  
>  while (<CHANGELOG>) {
>  	if (/^  CHANGELOG: /) {
>  		next if $printed;
>  
> +		$skip_newline = 1;
>  		while (<CHANGES>) {
> +			$skip_newline = 0;
>  			print NEW;
>  		}
>  
>  		$printed = 1;
>  	} else {
> +		if (/^$/) {
> +			if ($skip_newline == 1) {
> +				$skip_newline = 0;
> +				next;
> +			}
> +		}
>  		print NEW;
>  	}
>  }
> -- 
> 2.27.0
> 
> 
> -- 
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team
Thadeu Lima de Souza Cascardo Nov. 6, 2020, 11:33 a.m. UTC | #3
On Thu, Nov 05, 2020 at 05:02:52PM -0700, Kelsey Skunberg wrote:
> 
> Before applying could we get a BugLink to include?
> 

Sorry about that. How does that one look like?

BugLink: https://bugs.launchpad.net/bugs/1903293

> Otherwise lgtm.
> 
> Acked-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>
> 
> On 2020-11-05 13:16:43 , Thadeu Lima de Souza Cascardo wrote:
> > When some changes have been already added to the changelog, like when using
> > insert-ubuntu-changes, and there are no other changes, we end up with two
> > newlines right after the stanza header.
> > 
> > Add a $skip_newline variable that allows us to skip that extra newline when
> > there are no other changes.
> > 
> > Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
> > ---
> >  debian/scripts/misc/insert-changes.pl | 9 +++++++++
> >  1 file changed, 9 insertions(+)
> > 
> > diff --git a/debian/scripts/misc/insert-changes.pl b/debian/scripts/misc/insert-changes.pl
> > index c820597a9fc9..dde210faac34 100755
> > --- a/debian/scripts/misc/insert-changes.pl
> > +++ b/debian/scripts/misc/insert-changes.pl
> > @@ -13,17 +13,26 @@ open(CHANGES, "< $debian/changes") or die "Cannot open new changes";
> >  open(NEW, "> $debian/changelog.new") or die "Cannot open new changelog";
> >  
> >  $printed = 0;
> > +my $skip_newline = 0;
> >  
> >  while (<CHANGELOG>) {
> >  	if (/^  CHANGELOG: /) {
> >  		next if $printed;
> >  
> > +		$skip_newline = 1;
> >  		while (<CHANGES>) {
> > +			$skip_newline = 0;
> >  			print NEW;
> >  		}
> >  
> >  		$printed = 1;
> >  	} else {
> > +		if (/^$/) {
> > +			if ($skip_newline == 1) {
> > +				$skip_newline = 0;
> > +				next;
> > +			}
> > +		}
> >  		print NEW;
> >  	}
> >  }
> > -- 
> > 2.27.0
> > 
> > 
> > -- 
> > kernel-team mailing list
> > kernel-team@lists.ubuntu.com
> > https://lists.ubuntu.com/mailman/listinfo/kernel-team
Kleber Sacilotto de Souza Nov. 6, 2020, 4:28 p.m. UTC | #4
On 05.11.20 17:16, Thadeu Lima de Souza Cascardo wrote:
> When some changes have been already added to the changelog, like when using
> insert-ubuntu-changes, and there are no other changes, we end up with two
> newlines right after the stanza header.
> 
> Add a $skip_newline variable that allows us to skip that extra newline when
> there are no other changes.
> 
> Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>

Applied to {xenial,bionic,focal,groovy}/linux, with the BugLink added and
the change suggested by Andrea.

Thanks,
Kleber

> ---
>   debian/scripts/misc/insert-changes.pl | 9 +++++++++
>   1 file changed, 9 insertions(+)
> 
> diff --git a/debian/scripts/misc/insert-changes.pl b/debian/scripts/misc/insert-changes.pl
> index c820597a9fc9..dde210faac34 100755
> --- a/debian/scripts/misc/insert-changes.pl
> +++ b/debian/scripts/misc/insert-changes.pl
> @@ -13,17 +13,26 @@ open(CHANGES, "< $debian/changes") or die "Cannot open new changes";
>   open(NEW, "> $debian/changelog.new") or die "Cannot open new changelog";
>   
>   $printed = 0;
> +my $skip_newline = 0;
>   
>   while (<CHANGELOG>) {
>   	if (/^  CHANGELOG: /) {
>   		next if $printed;
>   
> +		$skip_newline = 1;
>   		while (<CHANGES>) {
> +			$skip_newline = 0;
>   			print NEW;
>   		}
>   
>   		$printed = 1;
>   	} else {
> +		if (/^$/) {
> +			if ($skip_newline == 1) {
> +				$skip_newline = 0;
> +				next;
> +			}
> +		}
>   		print NEW;
>   	}
>   }
>
Andrea Righi Nov. 27, 2020, 12:06 p.m. UTC | #5
Applied also to unstable (with the BugLink and the same changes done for
the other releases).

Thanks,
-Andrea

On Thu, Nov 05, 2020 at 01:16:43PM -0300, Thadeu Lima de Souza Cascardo wrote:
> When some changes have been already added to the changelog, like when using
> insert-ubuntu-changes, and there are no other changes, we end up with two
> newlines right after the stanza header.
> 
> Add a $skip_newline variable that allows us to skip that extra newline when
> there are no other changes.
> 
> Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
> ---
>  debian/scripts/misc/insert-changes.pl | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/debian/scripts/misc/insert-changes.pl b/debian/scripts/misc/insert-changes.pl
> index c820597a9fc9..dde210faac34 100755
> --- a/debian/scripts/misc/insert-changes.pl
> +++ b/debian/scripts/misc/insert-changes.pl
> @@ -13,17 +13,26 @@ open(CHANGES, "< $debian/changes") or die "Cannot open new changes";
>  open(NEW, "> $debian/changelog.new") or die "Cannot open new changelog";
>  
>  $printed = 0;
> +my $skip_newline = 0;
>  
>  while (<CHANGELOG>) {
>  	if (/^  CHANGELOG: /) {
>  		next if $printed;
>  
> +		$skip_newline = 1;
>  		while (<CHANGES>) {
> +			$skip_newline = 0;
>  			print NEW;
>  		}
>  
>  		$printed = 1;
>  	} else {
> +		if (/^$/) {
> +			if ($skip_newline == 1) {
> +				$skip_newline = 0;
> +				next;
> +			}
> +		}
>  		print NEW;
>  	}
>  }
> -- 
> 2.27.0
> 
> 
> -- 
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team
diff mbox series

Patch

diff --git a/debian/scripts/misc/insert-changes.pl b/debian/scripts/misc/insert-changes.pl
index c820597a9fc9..dde210faac34 100755
--- a/debian/scripts/misc/insert-changes.pl
+++ b/debian/scripts/misc/insert-changes.pl
@@ -13,17 +13,26 @@  open(CHANGES, "< $debian/changes") or die "Cannot open new changes";
 open(NEW, "> $debian/changelog.new") or die "Cannot open new changelog";
 
 $printed = 0;
+my $skip_newline = 0;
 
 while (<CHANGELOG>) {
 	if (/^  CHANGELOG: /) {
 		next if $printed;
 
+		$skip_newline = 1;
 		while (<CHANGES>) {
+			$skip_newline = 0;
 			print NEW;
 		}
 
 		$printed = 1;
 	} else {
+		if (/^$/) {
+			if ($skip_newline == 1) {
+				$skip_newline = 0;
+				next;
+			}
+		}
 		print NEW;
 	}
 }