blib/lib/Git/Raw/Commit.pm

filter: Statementstmt 100% 17 / 17 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 100% 24 / 24 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/Git/Raw/Cert/X509.pm ↑ Summary blib/lib/Git/Raw/Config.pm »
1 package Git::Raw::Commit;
2 87 $Git::Raw::Commit::VERSION = '0.90';
3 87 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 87 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 use overload
6 24 ▶ '""' => sub { return $_[0] -> id },
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
7 87 fallback => 1;
8  
9 87 ▶use Git::Raw;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 =head1 NAME
12  
13 Git::Raw::Commit - Git commit class
14  
15 =head1 VERSION
16  
17 version 0.90
18  
19 =head1 SYNOPSIS
20  
21 use Git::Raw;
22  
23 # open the Git repository at $path
24 my $repo = Git::Raw::Repository -> open($path);
25  
26 # add a file to the repository default index
27 my $index = $repo -> index;
28 $index -> add('test');
29 $index -> write;
30  
31 # create a new tree out of the repository index
32 my $tree_id = $index -> write_tree;
33 my $tree = $repo -> lookup($tree_id);
34  
35 # retrieve user's name and email from the Git configuration
36 my $config = $repo -> config;
37 my $name = $config -> str('user.name');
38 my $email = $config -> str('user.email');
39  
40 # create a new Git signature
41 my $me = Git::Raw::Signature -> now($name, $email);
42  
43 # create a new commit out of the above tree, with the repository HEAD as
44 # parent
45 my $commit = $repo -> commit(
46 'some commit', $me, $me, [ $repo -> head -> target ], $tree
47 );
48  
49 =head1 DESCRIPTION
50  
51 A C<Git::Raw::Commit> represents a Git commit.
52  
53 B<WARNING>: The API of this module is unstable and may change without warning
54 (any change will be appropriately documented in the changelog).
55  
56 =head1 METHODS
57  
58 =head2 create( $repo, $msg, $author, $committer, [@parents], $tree [, $update_ref ] )
59  
60 Create a new commit given a message, two L<Git::Raw::Signature> (one is the
61 commit author and the other the committer), a list of parent commits and a
62 L<Git::Raw::Tree>. If C<$update_ref> is provided and is defined, the reference
63 with the corresponding name is automatically updated or created. If
64 C<$update_ref> is C<undef>, no reference is updated. If C<$update_ref> is not
65 provided, "HEAD" is updated.
66  
67 =cut
68  
69 1 ▶sub amend {
Subroutine amend: called CC=1 SCAR=0.0
Pod documented
70 1 my $baseline = shift;
71 1 Git::Raw::Commit -> create(
72 $baseline -> owner(),
73 $baseline -> message,
74 $baseline -> author,
75 $baseline -> committer,
76 @_
77 );
78 }
79  
80 =head2 annotated( )
81  
82 Create a L<Git::Raw::AnnotatedCommit> from the commit.
83  
84 =head2 amend( $baseline, [@parents], $tree [, $update_ref ] )
85  
86 Create a new commit using C<$baseline> as a template for the message, author
87 and committer. This method is useful for rewriting a commit, by replacing its
88 parents and trees. See C<Git::Raw::Commit-E<gt>create()>
89  
90 =head2 lookup( $repo, $id )
91  
92 Retrieve the commit corresponding to C<$id>. This function is pretty much the
93 same as C<$repo-E<gt>lookup($id)> except that it only returns commits. If the
94 commit doesn't exist, this function will return C<undef>.
95  
96 =head2 owner( )
97  
98 Retrieve the L<Git::Raw::Repository> owning the commit.
99  
100 =head2 id( )
101  
102 Retrieve the id of the commit, as a string.
103  
104 =head2 message( )
105  
106 Retrieve the message of the commit.
107  
108 =head2 message_trailers( )
109  
110 Retrieve the message trailers of the commit. Returns a hash.
111  
112 =head2 summary( )
113  
114 Retrieve the summary of the commit message.
115  
116 =head2 body( )
117  
118 Retrieve the body of the commit message.
119  
120 =head2 author( )
121  
122 Retrieve the L<Git::Raw::Signature> representing the author of the commit.
123  
124 =head2 committer( )
125  
126 Retrieve the L<Git::Raw::Signature> representing the committer.
127  
128 =head2 time( )
129  
130 Retrieve the committer time of the commit.
131  
132 =head2 offset( )
133  
134 Retrieve the committer time offset (in minutes) of the commit.
135  
136 =head2 tree( )
137  
138 Retrieve the L<Git::Raw::Tree> the commit points to.
139  
140 =head2 parents( )
141  
142 Retrieve the list of parents of the commit.
143  
144 =head2 merge( $commit, [ \%merge_opts ])
145  
146 Merge C<$commit> into this commit. See C<Git::Raw::Repository-E<gt>merge()>
147 for valid C<%merge_opts> values. Returns a L<Git::Raw::Index> object
148 containing the merge result.
149  
150 =head2 ancestor( $gen )
151  
152 Retrieve the L<Git::Raw::Commit> object that is the C<$gen>'th generation
153 ancestor of this commit, following only the first parents.
154  
155 =head2 diff( [$parent_no, \%diff_opts] )
156  
157 Retrieve the diff associated with the commit. If the commit has no parents,
158 C<$parent_no> should not specified. Similarly, for merge commits, C<$parent_no>
159 should be specified. See C<Git::Raw::Repository-E<gt>diff()> for valid
160 C<%diff_opts> values. In this context, specifying a L<Git::Raw::Tree> in
161 C<%diff_opts> will have no effect as it will be determined from the commit's
162 parent.
163  
164 =head2 as_email( [\%format_opts, \%diff_opts] )
165  
166 Retrieve the patch e-mail associated with the commit. See
167 C<Git::Raw::Repository-E<gt>diff()> for valid C<%diff_opts> values. In this
168 context, specifying a L<Git::Raw::Tree> in C<%diff_opts> will have no effect
169 as it will be determined from the commit's parent. Valid fields for the
170 C<%format_opts> hash are:
171  
172 =over 4
173  
174 =item * "patch_no"
175  
176 The patch number for this commit.
177  
178 =item * "total_patches"
179  
180 Total number of patches.
181  
182 =item * "flags"
183  
184 E-mail generation flags. Valid fields for this hash include:
185  
186 =over 8
187  
188 =item * "exclude_subject_patch_marker"
189  
190 Don't insert C<"[PATCH]"> in the subject header.
191  
192 =back
193  
194 =back
195  
196 =head1 AUTHOR
197  
198 Alessandro Ghedini <alexbio@cpan.org>
199  
200 Jacques Germishuys <jacquesg@cpan.org>
201  
202 =head1 LICENSE AND COPYRIGHT
203  
204 Copyright 2012 Alessandro Ghedini.
205  
206 This program is free software; you can redistribute it and/or modify it
207 under the terms of either: the GNU General Public License as published
208 by the Free Software Foundation; or the Artistic License.
209  
210 See http://dev.perl.org/licenses/ for more information.
211  
212 =cut
213  
214 87 1; # End of Git::Raw::Commit
« blib/lib/Git/Raw/Cert/X509.pm ↑ Summary blib/lib/Git/Raw/Config.pm »