summaryrefslogtreecommitdiff
path: root/v4l/scripts/prep_commit_msg.pl
blob: 239fb609212a65283fb2570ba73075b454ca8d31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/perl

$f=shift; 
open IN,"<$f"; 
my $n=2;
my $from="";
my $first="";
my $changed="";
$out="";
while (<IN>) {
	if (m/^[0-9]/) {
		$n--;
		next;
	}
	if ($n>0) {
		s/[\t -]*//;
		if (m/^\* (.*):/) {
			$changed="#\t$1\n$changed";
		} else {
			if ($first eq "") {
				if ($_ eq "\n") {
					next;
				}
				$first="$_";
				next;
			}
			if ($from eq "") {
				if (m/Signed-off-by:/) {
					$from = $_;
					$from =~ s/Signed-off-by/From/;
					$first="$first\n#\n# Then From line\n$from\n";
				}
			}
			$out="$out$_";
		}
	} 
}
printf  "#Added/removed/changed files:\n%s" .
	"# First line should be the subject, without Subject:\n%s" .
	"# Then a detailed description followed by Signed-off-by: fields:\n%s",
	$changed,$first,$out;