line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
# Created on: 2014-03-11 20:58:59 |
3
|
|
|
|
|
|
|
# Create by: Ivan Wills |
4
|
|
|
|
|
|
|
# $Id$ |
5
|
|
|
|
|
|
|
# $Revision$, $HeadURL$, $Date$ |
6
|
|
|
|
|
|
|
# $Revision$, $Source$, $Date$ |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use strict; |
9
|
2
|
|
|
2
|
|
77151
|
use warnings; |
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
48
|
|
10
|
2
|
|
|
2
|
|
8
|
use version; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
42
|
|
11
|
2
|
|
|
2
|
|
315
|
use English qw/ -no_match_vars /; |
|
2
|
|
|
|
|
1366
|
|
|
2
|
|
|
|
|
9
|
|
12
|
2
|
|
|
2
|
|
522
|
use Pod::Usage; |
|
2
|
|
|
|
|
2546
|
|
|
2
|
|
|
|
|
9
|
|
13
|
2
|
|
|
2
|
|
970
|
use Term::ANSIColor qw/colored/; |
|
2
|
|
|
|
|
41640
|
|
|
2
|
|
|
|
|
182
|
|
14
|
2
|
|
|
2
|
|
539
|
use JSON qw/decode_json encode_json/; |
|
2
|
|
|
|
|
6839
|
|
|
2
|
|
|
|
|
594
|
|
15
|
2
|
|
|
2
|
|
1079
|
use App::Git::Workflow; |
|
2
|
|
|
|
|
14021
|
|
|
2
|
|
|
|
|
11
|
|
16
|
2
|
|
|
2
|
|
632
|
use App::Git::Workflow::Command qw/get_options/; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
87
|
|
17
|
2
|
|
|
2
|
|
398
|
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
1852
|
|
18
|
|
|
|
|
|
|
our $VERSION = version->new(1.1.20); |
19
|
|
|
|
|
|
|
our $workflow = App::Git::Workflow->new; |
20
|
|
|
|
|
|
|
our ($name) = $PROGRAM_NAME =~ m{^.*/(.*?)$}mxs; |
21
|
|
|
|
|
|
|
our %p2u_extra; |
22
|
|
|
|
|
|
|
our %option; |
23
|
|
|
|
|
|
|
our %cmd_map = ( |
24
|
|
|
|
|
|
|
( map { $_ => $_ } qw/add list switch delete/ ), |
25
|
|
|
|
|
|
|
ls => 'list', |
26
|
|
|
|
|
|
|
rm => 'delete', |
27
|
|
|
|
|
|
|
sw => 'switch', |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my ($self) = @_; |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
0
|
1
|
|
get_options( \%option, 'commitish|c=s', 'number|n=i', 'force|f!', |
33
|
|
|
|
|
|
|
'verbose|v+' ); |
34
|
0
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my $action = 'do_' . ( $cmd_map{ $ARGV[0] || 'add' } || '' ); |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
0
|
|
|
|
if ( !$self->can($action) ) { |
38
|
|
|
|
|
|
|
warn "Unknown action $ARGV[0]!\n"; |
39
|
0
|
0
|
|
|
|
|
Pod::Usage::pod2usage( %p2u_extra, -verbose => 1 ); |
40
|
0
|
|
|
|
|
|
return 1; |
41
|
0
|
|
|
|
|
|
} |
42
|
0
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$self->$action(); |
44
|
|
|
|
|
|
|
} |
45
|
0
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my ($self) = @_; |
47
|
|
|
|
|
|
|
my $memo = $self->get_memos(); |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
0
|
0
|
|
my $commitish |
50
|
0
|
|
|
|
|
|
= $option{commitish} |
51
|
|
|
|
|
|
|
|| $ARGV[-1] |
52
|
|
|
|
|
|
|
|| $workflow->git->rev_parse( '--abbrev-ref', 'HEAD' ); |
53
|
|
|
|
|
|
|
chomp $commitish; |
54
|
0
|
|
0
|
|
|
|
|
55
|
|
|
|
|
|
|
$memo->{names}{$commitish} = { |
56
|
0
|
|
|
|
|
|
date => time, |
57
|
|
|
|
|
|
|
sha => $workflow->git->log( '-n1', '--format=format:%H', $commitish ), |
58
|
0
|
|
|
|
|
|
}; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
$self->set_memos($memo); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
my ( $self, $memo, $type ) = @_; |
64
|
|
|
|
|
|
|
my $name; |
65
|
|
|
|
|
|
|
$option{number} //= pop @ARGV; |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
0
|
0
|
|
if ( $option{commitish} && $memo->{names}{ $option{commitish} } ) { |
68
|
0
|
|
|
|
|
|
$name = $option{commitish}; |
69
|
0
|
|
0
|
|
|
|
} |
70
|
|
|
|
|
|
|
elsif ( $option{number} eq $type ) { |
71
|
0
|
0
|
0
|
|
|
|
warn "git memo $type requires an argument!\n"; |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
Pod::Usage::pod2usage( %p2u_extra, -verbose => 1 ); |
73
|
|
|
|
|
|
|
return; |
74
|
|
|
|
|
|
|
} |
75
|
0
|
|
|
|
|
|
elsif ( defined $option{number} ) { |
76
|
0
|
|
|
|
|
|
my $i = 0; |
77
|
0
|
|
|
|
|
|
for my $memo_item ( sort keys %{ $memo->{names} } ) { |
78
|
|
|
|
|
|
|
if ( $i++ == $option{number} ) { |
79
|
|
|
|
|
|
|
$name = $memo_item; |
80
|
0
|
|
|
|
|
|
last; |
81
|
0
|
|
|
|
|
|
} |
|
0
|
|
|
|
|
|
|
82
|
0
|
0
|
|
|
|
|
} |
83
|
0
|
|
|
|
|
|
} |
84
|
0
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
die "No branch/tag/commit found matching " |
86
|
|
|
|
|
|
|
. ( $option{number} || $option{commitish} ) . "!\n" |
87
|
|
|
|
|
|
|
if !$name; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
return $name; |
90
|
0
|
0
|
0
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
my ($self) = @_; |
93
|
0
|
|
|
|
|
|
my $memo = $self->get_memos(); |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
my $name = $self->commit_name( $memo, 'delete' ); |
96
|
|
|
|
|
|
|
return if !$name; |
97
|
0
|
|
|
0
|
0
|
|
delete $memo->{names}{$name}; |
98
|
0
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
$self->set_memos($memo); |
100
|
0
|
|
|
|
|
|
} |
101
|
0
|
0
|
|
|
|
|
|
102
|
0
|
|
|
|
|
|
my ($self) = @_; |
103
|
|
|
|
|
|
|
my $memo = $self->get_memos(); |
104
|
0
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
my $name = $self->commit_name( $memo, 'switch' ); |
106
|
|
|
|
|
|
|
return if !$name; |
107
|
|
|
|
|
|
|
$workflow->git->checkout($name); |
108
|
0
|
|
|
0
|
0
|
|
|
109
|
0
|
|
|
|
|
|
$memo->{last} = $name; |
110
|
|
|
|
|
|
|
$self->set_memos($memo); |
111
|
0
|
|
|
|
|
|
|
112
|
0
|
0
|
|
|
|
|
$self->do_list(); |
113
|
0
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
my ($self) = @_; |
116
|
0
|
|
|
|
|
|
my $memo = $self->get_memos(); |
117
|
|
|
|
|
|
|
my $i = 0; |
118
|
0
|
|
|
|
|
|
my $max = int( log( keys %{ $memo->{names} } ) / log(10) ) + 1; |
119
|
|
|
|
|
|
|
my $current = $workflow->git->rev_parse( '--abbrev-ref', 'HEAD' ); |
120
|
|
|
|
|
|
|
chomp $current; |
121
|
|
|
|
|
|
|
my $sha = $workflow->git->log( '-n1', '--format=format:%H', $current ); |
122
|
0
|
|
|
0
|
0
|
|
|
123
|
0
|
|
|
|
|
|
for my $memo_item ( sort keys %{ $memo->{names} } ) { |
124
|
0
|
|
|
|
|
|
my $marker |
125
|
0
|
|
|
|
|
|
= $memo_item eq $current ? '*' |
|
0
|
|
|
|
|
|
|
126
|
0
|
|
|
|
|
|
: $memo_item eq $memo->{last} ? '#' |
127
|
0
|
|
|
|
|
|
: $memo->{names}{$memo_item}{sha} eq $sha ? '-' |
128
|
0
|
|
|
|
|
|
: ' '; |
129
|
|
|
|
|
|
|
my $date = ''; |
130
|
0
|
|
|
|
|
|
if ( $option{verbose} ) { |
|
0
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) |
132
|
|
|
|
|
|
|
= localtime( $memo->{names}{$memo_item}{date} ); |
133
|
|
|
|
|
|
|
$mon++; |
134
|
0
|
0
|
|
|
|
|
$year += 1900; |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
135
|
|
|
|
|
|
|
$date = sprintf "%04i-%02i-%02i %02i:%02i:%02i ", $year, |
136
|
0
|
|
|
|
|
|
$mon, $mday, $hour, $min, $sec; |
137
|
0
|
0
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
|
printf "[%${max}i] %s%s %s\n", $i++, $date, $marker, $memo_item; |
140
|
0
|
|
|
|
|
|
} |
141
|
0
|
|
|
|
|
|
} |
142
|
0
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
my ( $self, $json ) = @_; |
144
|
|
|
|
|
|
|
my $git_dir = $workflow->git->rev_parse("--show-toplevel"); |
145
|
|
|
|
|
|
|
chomp $git_dir; |
146
|
0
|
|
|
|
|
|
my $memo = "$git_dir/.git/memo.json"; |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
open my $fh, '>', $memo or die "Can't write to $memo: $!"; |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
print {$fh} encode_json($json), "\n"; |
151
|
0
|
|
|
0
|
0
|
|
} |
152
|
0
|
|
|
|
|
|
|
153
|
0
|
|
|
|
|
|
my ($self) = @_; |
154
|
0
|
|
|
|
|
|
my $git_dir = $workflow->git->rev_parse("--show-toplevel"); |
155
|
|
|
|
|
|
|
chomp $git_dir; |
156
|
0
|
0
|
|
|
|
|
my $memo = "$git_dir/.git/memo.json"; |
157
|
|
|
|
|
|
|
|
158
|
0
|
|
|
|
|
|
if ( !-f $memo ) { |
|
0
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
return { last => '', names => {} }; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
0
|
|
|
0
|
0
|
|
open my $fh, '<', $memo or die "Can't open $memo: $!"; |
163
|
0
|
|
|
|
|
|
my $json_text = join '', <$fh>; |
164
|
0
|
|
|
|
|
|
|
165
|
0
|
|
|
|
|
|
my $json = decode_json($json_text); |
166
|
|
|
|
|
|
|
|
167
|
0
|
0
|
|
|
|
|
$json->{last} ||= ''; |
168
|
0
|
|
|
|
|
|
return $json; |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
0
|
0
|
|
|
|
|
1; |
172
|
0
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
|
174
|
0
|
|
|
|
|
|
=head1 NAME |
175
|
|
|
|
|
|
|
|
176
|
0
|
|
0
|
|
|
|
git-memo - Help Memo many commits |
177
|
0
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head1 VERSION |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
This documentation refers to git-memo version 1.1.20 |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=head1 SYNOPSIS |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
git-memo [add] [(-c|--commitish)[=]sha|branch|tag] |
185
|
|
|
|
|
|
|
git-memo (list|ls) |
186
|
|
|
|
|
|
|
git-memo (switch|sw) (-n|--number) number |
187
|
|
|
|
|
|
|
git-memo (delete|rm) (-n|--number) number [--force|-f] |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
SUB-COMMAND: |
190
|
|
|
|
|
|
|
add Add either the current branch/commit/etc or a specified commitish to the memo list |
191
|
|
|
|
|
|
|
list List all memoed commitishes |
192
|
|
|
|
|
|
|
switch Switch to a saved memoed commitish |
193
|
|
|
|
|
|
|
delete Delete a saved memoed commitish |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
OPTIONS: |
196
|
|
|
|
|
|
|
-c --commitish[=]sha|branch|tag |
197
|
|
|
|
|
|
|
The specified commit to add to the memo list |
198
|
|
|
|
|
|
|
-n --number[=]int |
199
|
|
|
|
|
|
|
A memoed commitish to switch to |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
-v --verbose Show more detailed option |
202
|
|
|
|
|
|
|
--version Prints the version information |
203
|
|
|
|
|
|
|
--help Prints this help information |
204
|
|
|
|
|
|
|
--man Prints the full documentation for git-memo |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=head1 DESCRIPTION |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
Memo current branch, commit or tag to make finding them easier in the future. |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head2 C<run ()> |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
Executes the git workflow command |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=head1 DIAGNOSTICS |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=head1 CONFIGURATION AND ENVIRONMENT |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=head1 INCOMPATIBILITIES |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
There are no known bugs in this module. |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
Please report problems to Ivan Wills (ivan.wills@gmail.com). |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
Patches are welcome. |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=head1 AUTHOR |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
Ivan Wills - (ivan.wills@gmail.com) |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
Copyright (c) 2014 Ivan Wills (14 Mullion Close, Hornsby Heights, NSW Australia 2077). |
239
|
|
|
|
|
|
|
All rights reserved. |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or modify it under |
242
|
|
|
|
|
|
|
the same terms as Perl itself. See L<perlartistic>. This program is |
243
|
|
|
|
|
|
|
distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
244
|
|
|
|
|
|
|
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
245
|
|
|
|
|
|
|
PARTICULAR PURPOSE. |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=cut |