summaryrefslogtreecommitdiff
path: root/pwx
diff options
context:
space:
mode:
authorSven Eden <yamakuzure@gmx.net>2018-03-16 06:56:25 +0100
committerSven Eden <yamakuzure@gmx.net>2018-03-26 18:26:00 +0200
commited4f44ecdb66887a5a207a8df3a494a33654003a (patch)
tree3df4eace93d1d5497b47499c8435fd6435bad4ef /pwx
parent39a92368a22357f91d90af998e652372c9e7c339 (diff)
check_tree.pl: Do not remove empty lines prior masks/inserts. Do not rename 'systemd' in mask blocks.
Diffstat (limited to 'pwx')
-rwxr-xr-xpwx/check_tree.pl44
1 files changed, 32 insertions, 12 deletions
diff --git a/pwx/check_tree.pl b/pwx/check_tree.pl
index 299ea6d2f..66283db74 100755
--- a/pwx/check_tree.pl
+++ b/pwx/check_tree.pl
@@ -892,6 +892,13 @@ sub check_masks {
and return hunk_failed("check_masks: Mask start found while being in an insert block!");
substr($$line, 0, 1) = " "; ## Remove '-'
$in_mask_block = 1;
+
+ # While we are here we can check the previous line.
+ # All masks shall be preceded by an empty line to enhance readability.
+ # So any attempt to remove them must be stopped.
+ ($i > 0) and ($hHunk->{lines}[$i-1] =~ m/^-\s*$/)
+ and substr($hHunk->{lines}[$i-1], 0, 1) = " ";
+
next;
}
@@ -905,6 +912,13 @@ sub check_masks {
and return hunk_failed("check_masks: Insert start found while being in an insert block!");
substr($$line, 0, 1) = " "; ## Remove '-'
$in_insert_block = 1;
+
+ # While we are here we can check the previous line.
+ # All inserts shall be preceded by an empty line to enhance readability.
+ # So any attempt to remove them must be stopped.
+ ($i > 0) and ($hHunk->{lines}[$i-1] =~ m/^-\s*$/)
+ and substr($hHunk->{lines}[$i-1], 0, 1) = " ";
+
next;
}
@@ -1055,14 +1069,14 @@ sub check_name_reverts {
# Note down removals
# ---------------------------------
- if ($$line =~ m/^-[#]?\s*(.*elogind.*)\s*$/) {
- $hRemovals{$1}{line} = $i;
+ if ($$line =~ m/^-[# ]*\s*(.*elogind.*)\s*$/) {
+ $hRemovals{$1}{line} = $i;
next;
}
# Check Additions
# ---------------------------------
- if ($$line =~ m/^\+[#]?\s*(.*systemd.*)\s*$/) {
+ if ($$line =~ m/^\+[# ]*\s*(.*systemd.*)\s*$/) {
my $replace_text = $1;
my $our_text_long = $replace_text;
my $our_text_short = $our_text_long;
@@ -1079,21 +1093,27 @@ sub check_name_reverts {
# 2) References to the systemd github site must not be changed
$replace_text =~ m,github\.com/systemd, and next;
- # If this is a simple switch, undo it:
- if ( defined($hRemovals{$our_text_short})
- || defined($hRemovals{$our_text_long }) ) {
- defined($hRemovals{$our_text_short} )
- and substr($hHunk->{lines}[$hRemovals{$our_text_short}{line}], 0, 1) = " "
- or substr($hHunk->{lines}[$hRemovals{$our_text_long }{line}], 0, 1) = " ";
+ # Make the following easier with a simple shortcut:
+ my $o_txt = defined($hRemovals{$our_text_long }) ? $our_text_long :
+ defined($hRemovals{$our_text_short}) ? $our_text_short :
+ "";
+
+ # --- Case A) If this is a simple switch, undo it. ---
+ # ----------------------------------------------------
+ if ( length($o_txt) ) {
+ substr($hHunk->{lines}[$hRemovals{$o_txt}{line}], 0, 1) = " ";
splice(@{$hHunk->{lines}}, $i--, 1);
$hHunk->{count}--;
next;
}
- # Otherwise replace the addition with our text. ;-)
+ # --- Case B) Otherwise replace the addition with our text. ---
+ # --- Unless we are in a mask block. ---
+ # -------------------------------------------------------------
+ $in_mask_block and next;
$our_text_long eq $replace_text
- and $$line =~ s/^\+([#]?\s*).*systemd.*(\s*)$/+${1}${our_text_short}${2}/
- or $$line =~ s/^\+([#]?\s*).*systemd.*(\s*)$/+${1}${our_text_long }${2}/;
+ and $$line =~ s/^\+([# ]*\s*).*systemd.*(\s*)$/+${1}${our_text_short}${2}/
+ or $$line =~ s/^\+([# ]*\s*).*systemd.*(\s*)$/+${1}${our_text_long }${2}/;
}
}