[Secure-testing-commits] r56663 - bin

Raphael Geissert geissert at moszumanska.debian.org
Thu Oct 12 19:58:56 UTC 2017


Author: geissert
Date: 2017-10-12 19:58:56 +0000 (Thu, 12 Oct 2017)
New Revision: 56663

Modified:
   bin/check-new-issues
Log:
poor-man's pkg name completion

only based on package names already seen in the list, at this time


Modified: bin/check-new-issues
===================================================================
--- bin/check-new-issues	2017-10-12 19:52:49 UTC (rev 56662)
+++ bin/check-new-issues	2017-10-12 19:58:56 UTC (rev 56663)
@@ -144,6 +144,8 @@
 	$ignore_missing_bug{$_} = 1 for @ignore_missing_bug_list;
 }
 
+my %seen_pkgs;
+
 foreach my $entry (@{$entries}) {
 	my $name;
 	if ( $entry =~ /^(CVE-....-\d{4,})/ ) {
@@ -155,6 +157,14 @@
 	else {
 		die "invlid entry:\n$entry";
 	}
+	if (!$opts{l} && $entry =~ /^\s+-\s+([^\s]+)/m ) {
+	    my $pkg = $1;
+	    my $fc = substr($pkg, 0, 1);
+
+	    $seen_pkgs{$fc} = {}
+		    unless (exists($seen_pkgs{$fc}));
+	    $seen_pkgs{$fc}{$pkg} = undef;
+	}
 	$data->{$name}->{entry}=\$entry;
 	if ($name =~ /$issue_regexp/) {
 		if (!$opts{U} && $entry =~ /$todo_regexp/m ) {
@@ -211,7 +221,7 @@
 
 my $attribs = $term->Attribs;
 
-$attribs->{completion_word} = [ qw(.f .c .w .m .r ! v e - .help q) ];
+my @completion_commands = qw(.f .c .w .m .r ! v e - .help q);
 
 sub initial_completion {
     my ($text, $line, $start, $end) = @_;
@@ -221,12 +231,28 @@
 
     # If first word then complete commands
     if ($start == 0) {
+	$attribs->{completion_word} = \@completion_commands;
+
 	# do not add useless blank spaces on completion
 	$attribs->{completion_suppress_append} = 1
 		unless ($line eq '-');
 
 	return $term->completion_matches($text,
 					 $attribs->{list_completion_function});
+    } elsif ($line =~ /^-\s+(.)?/) {
+	my $fc = $1;
+
+	if (length($fc) == 0) {
+	    $attribs->{completion_suppress_append} = 1;
+	    $attribs->{completion_word} = [ keys %seen_pkgs ];
+	} elsif (exists($seen_pkgs{$fc})) {
+	    $attribs->{completion_word} = [ keys %{$seen_pkgs{$fc}} ];
+	} else {
+	    $attribs->{completion_word} = [];
+	}
+
+	return $term->completion_matches($text,
+					 $attribs->{list_completion_function});
     } else {
 	return;
     }




More information about the Secure-testing-commits mailing list