-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathav-list-old-notes
executable file
·51 lines (38 loc) · 1.32 KB
/
av-list-old-notes
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
42
43
44
45
46
47
48
49
50
#!/usr/bin/env perl
use warnings;
use strict;
use feature qw/say/;
use Git::Repository;
use Data::Printer;
use lib::abs 'lib';
use Git::WorkFlow::AstraVer::Notes;
use Git::WorkFlow::AstraVer::Commit qw/short_commit_info/;
use Git::WorkFlow::AstraVer::Branch qw/branch_contains list_branches_sorted/;
use List::Util qw/any/;
my $r = Git::Repository->new(work_tree => $ENV{CURRENT_PROJECT});
my ($latest_devel, $latest_spec);
{
my @devel_branches = list_branches_sorted($r, 'devel-*');
die "Can't find versioned devel branches.\n"
unless @devel_branches;
$latest_devel = $devel_branches[-1];
my @spec_branches = list_branches_sorted($r, 'spec-*');
die "Can't find versioned devel branches.\n"
unless @spec_branches;
$latest_spec = $spec_branches[-1];
}
print "LATEST_DEVEL: $latest_devel\n";
print "LATEST_SPEC: $latest_spec\n";
my %notes;
foreach ($r->run('notes')) {
my @tmp = split ' ';
$notes{$tmp[1]}{content} = Git::WorkFlow::AstraVer::Notes::_note_content($r, $tmp[0]);
$notes{$tmp[1]}{commit_info} = short_commit_info($r, $tmp[1]);
$notes{$tmp[1]}{branch} = [ branch_contains($r, $tmp[1]) ];
}
foreach (keys %notes) {
unless (any {$_ ne $latest_devel && $_ ne $latest_spec && $_ ne 'spec' && $_ ne 'devel'} @{$notes{$_}{branch}}) {
delete $notes{$_}
}
}
p %notes;