line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Giblog::Command::save; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1484
|
use base 'Giblog::Command'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
479
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
18
|
|
6
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
7
|
1
|
|
|
1
|
|
675
|
use Mojolicious; |
|
1
|
|
|
|
|
621407
|
|
|
1
|
|
|
|
|
17
|
|
8
|
1
|
|
|
1
|
|
2568
|
use Time::Piece 'localtime'; |
|
1
|
|
|
|
|
11035
|
|
|
1
|
|
|
|
|
10
|
|
9
|
1
|
|
|
1
|
|
154
|
use Getopt::Long 'GetOptions'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
13
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
190
|
use Carp 'confess'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
504
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub run { |
14
|
0
|
|
|
0
|
1
|
|
my ($self, @argv) = @_; |
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
|
|
|
my $message; |
17
|
|
|
|
|
|
|
{ |
18
|
0
|
|
|
|
|
|
local @ARGV = @argv; |
|
0
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
my $getopt_option_save = Getopt::Long::Configure(qw(default no_auto_abbrev no_ignore_case)); |
20
|
0
|
|
|
|
|
|
GetOptions( |
21
|
|
|
|
|
|
|
'm=s' => \$message, |
22
|
|
|
|
|
|
|
); |
23
|
0
|
|
|
|
|
|
Getopt::Long::Configure($getopt_option_save); |
24
|
0
|
|
|
|
|
|
@argv = @ARGV; |
25
|
|
|
|
|
|
|
} |
26
|
0
|
|
|
|
|
|
my ($remote_rep, $branch) = @argv; |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
my $api = $self->api; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
my $home_dir = $api->rel_file('.'); |
31
|
|
|
|
|
|
|
|
32
|
0
|
0
|
|
|
|
|
unless (defined $message) { |
33
|
0
|
|
|
|
|
|
confess 'Must be specify message using -m option'; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
0
|
0
|
|
|
|
|
unless (defined $remote_rep) { |
37
|
0
|
|
|
|
|
|
confess 'Must be specify remote repository name'; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
0
|
0
|
|
|
|
|
unless (defined $branch) { |
41
|
0
|
|
|
|
|
|
confess 'Must be specify branch name'; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
my @git_add_command = ('git', '-C', $home_dir, 'add', '--all'); |
45
|
0
|
0
|
|
|
|
|
if (system(@git_add_command) == -1) { |
46
|
0
|
|
|
|
|
|
confess "Fail giblog save command. Command is @git_add_command: $?"; |
47
|
|
|
|
|
|
|
} |
48
|
0
|
|
|
|
|
|
my @git_commit_command = ('git', '-C', $home_dir, 'commit', '-m', $message); |
49
|
0
|
0
|
|
|
|
|
if(system(@git_commit_command) == -1) { |
50
|
0
|
|
|
|
|
|
confess "Fail giblog save command. Command is @git_commit_command : $?"; |
51
|
|
|
|
|
|
|
} |
52
|
0
|
|
|
|
|
|
my @git_push_command = ('git', '-C', $home_dir, 'push', $remote_rep, $branch); |
53
|
0
|
0
|
|
|
|
|
if (system(@git_push_command) == -1) { |
54
|
0
|
|
|
|
|
|
confess "Fail giblog save command. Command is @git_push_command : $?"; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=encoding utf8 |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 NAME |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Giblog::Command::save - save command |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 DESCRIPTION |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
L is save command. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 METHODS |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
L inherits all methods from L and |
73
|
|
|
|
|
|
|
implements the following new ones. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head2 run |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
$command->run('-m', $message, $remote_repository, $branch); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
save command executes the following git commands(add, commit, push). |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
This is the same as the following command. In this example, the commit message is "Hello". the repository name is "origin". the branch name is "main". |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
git add --all |
84
|
|
|
|
|
|
|
git commit -m "Hello" |
85
|
|
|
|
|
|
|
git push origin main |