blib/lib/LCFG/Build/VCS/None.pm

filter: Statementstmt 33.6% 33 / 98 Branchbran 0.0% 0 / 38 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 9 / 18 Podpod 100% 8 / 8 totaltotal 30.8% 50 / 162 SCAR 52.7
CC
20
Cov
24%
checkout_project
56.0
export
30.0
tagversion
20.0
CRAP 193.8
« blib/lib/LCFG/Build/VCS.pm ↑ Summary Build »
1 package LCFG::Build::VCS::None; # -*-perl-*-
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 # $Id: None.pm.in 29257 2015-11-12 15:42:14Z squinney@INF.ED.AC.UK $
6 # $Source: /var/cvs/dice/LCFG-Build-VCS/lib/LCFG/Build/VCS/None.pm.in,v $
7 # $Revision: 29257 $
8 # $HeadURL: https://svn.lcfg.org/svn/source/tags/LCFG-Build-VCS/LCFG_Build_VCS_0_2_3/lib/LCFG/Build/VCS/None.pm.in $
9 # $Date: 2015-11-12 15:42:14 +0000 (Thu, 12 Nov 2015) $
10  
11 1 our $VERSION = '0.2.3';
12  
13 1 ▶use File::Copy::Recursive ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use File::HomeDir ();
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use File::Path ();
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use File::Spec ();
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use IO::Dir ();
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 with 'LCFG::Build::VCS';
21  
22 has 'tagdir' => (
23 is => 'rw',
24 isa => 'Str',
25 lazy => 1,
26 0 ▶ default => sub { File::Spec->catdir( File::HomeDir->my_home(),
Subroutine __ANON__: not called CC=1 SCAR=6.9
27 'lcfgbuild', 'tags' ) },
28 1 );
29  
30 1 has '+id' => ( default => 'None' );
31  
32 # This should give a speed-up in loading
33  
34 1 __PACKAGE__->meta->make_immutable;
35  
36 sub checkcommitted {
37 0 ▶ return 1;
Subroutine checkcommitted: not called CC=1 SCAR=6.9
Pod documented
38 }
39  
40 sub genchangelog {
41 0 ▶ return;
Subroutine genchangelog: not called CC=1 SCAR=6.9
Pod documented
42 }
43  
44 sub run_cmd {
45 0 ▶ return;
Subroutine run_cmd: not called CC=1 SCAR=6.9
Pod documented
46 }
47  
48 sub tagversion {
49 0 ▶ my ( $self, $version ) = @_;
Subroutine tagversion: not called CC=4 SCAR=30.0
Pod documented
50  
51 0 my $module = $self->module;
52  
53 0 $self->update_changelog($version);
54  
55 0 my $tag = $self->gen_tag($version);
56 0 my $tagdir = File::Spec->catdir( $self->tagdir, $module, $tag );
57  
58 0 ▶ if ( !$self->dryrun ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->dryrun) 0 0 0
59 0 ▶ if ( -d $tagdir ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-d $tagdir) 0 0 0
60 0 File::Path::rmtree($tagdir);
61 }
62 0 ▶ File::Copy::Recursive::dircopy( $self->workdir, $tagdir )
Branch: 1 branch
BranchTrueFalseTotal
File::Copy::Recursive::dircopy($self->workdir, $tagdir) or die "Could not tag $module at $version\n" 0 0 0
63 or die "Could not tag $module at $version\n";
64 }
65  
66 0 return;
67 }
68  
69 sub export {
70 0 ▶ my ( $self, $version, $builddir ) = @_;
Subroutine export: not called CC=5 SCAR=34.0
Pod documented
71  
72 0 my $module = $self->module;
73  
74 0 my $tag = $self->gen_tag($version);
75 0 my $storedir = File::Spec->catdir( $self->tagdir, $module, $tag );
76  
77 0 ▶ if ( !-d $storedir ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $storedir) 0 0 0
78 0 die "Could not find stored tag for $version of $module in $storedir\n";
79 }
80  
81 0 my $target = join q{-}, $module, $version;
82 0 my $exportdir = File::Spec->catdir( $builddir, $target );
83  
84 0 ▶ if ( !$self->dryrun ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->dryrun) 0 0 0
85 0 ▶ if ( -d $exportdir ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-d $exportdir) 0 0 0
86 0 File::Path::rmtree($exportdir);
87 }
88 0 ▶ File::Copy::Recursive::dircopy( $storedir, $exportdir )
Branch: 1 branch
BranchTrueFalseTotal
File::Copy::Recursive::dircopy($storedir, $exportdir) or die "Could not copy $storedir to $exportdir\n" 0 0 0
89 or die "Could not copy $storedir to $exportdir\n";
90 }
91  
92 0 return $exportdir;
93 }
94  
95 sub export_devel {
96 0 ▶ my ( $self, $version, $builddir ) = @_;
Subroutine export_devel: not called CC=4 SCAR=30.0
Pod documented
97  
98 0 my $module = $self->module;
99  
100 0 my $target = join q{-}, $module, $version;
101 0 my $exportdir = File::Spec->catdir( $builddir, $target );
102  
103 0 ▶ if ( !$self->dryrun ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->dryrun) 0 0 0
104 0 ▶ if ( -d $exportdir ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-d $exportdir) 0 0 0
105 0 File::Path::rmtree($exportdir);
106 }
107 0 my $workdir = $self->workdir;
108 0 ▶ File::Copy::Recursive::dircopy( $workdir, $exportdir )
Branch: 1 branch
BranchTrueFalseTotal
File::Copy::Recursive::dircopy($workdir, $exportdir) or die "Could not copy $workdir to $exportdir\n" 0 0 0
109 or die "Could not copy $workdir to $exportdir\n";
110 }
111  
112 0 return $exportdir;
113  
114 }
115  
116 sub checkout_project {
117 0 ▶ my ( $self, $version, $outdir ) = @_;
Subroutine checkout_project: not called CC=7 SCAR=40.3
Pod documented
118  
119 0 my $module = $self->module;
120 0 my $basedir = File::Spec->catdir( $self->tagdir, $module );
121  
122 0 ▶ if ( !-d $basedir ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $basedir) 0 0 0
123 0 die "Could not find the tag directory for $module\n";
124 }
125  
126 0 my $tag;
127 0 ▶ if ( defined $version ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $version) { } 0 0 0
128 0 $tag = $self->gen_tag($version);
129 }
130 else {
131 0 tie my %dir, 'IO::Dir', $basedir;
132 0 $tag = (sort grep { !m/^\./} keys %dir)[-1];
133 }
134  
135 0 my $tagdir = File::Spec->catdir( $basedir, $tag );
136  
137 0 ▶ if ( !-d $tagdir ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $tagdir) 0 0 0
138 0 die "Could not find the tag $tag for $module\n";
139 }
140  
141 0 ▶ if ( !defined $outdir ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $outdir) 0 0 0
142 0 $outdir = $module;
143 }
144  
145 0 ▶ if ( !$self->dryrun ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->dryrun) 0 0 0
146 0 ▶ File::Copy::Recursive::dircopy( $tagdir, $outdir )
Branch: 1 branch
BranchTrueFalseTotal
File::Copy::Recursive::dircopy($tagdir, $outdir) or die "Could not checkout $module tag $tag\n" 0 0 0
147 or die "Could not checkout $module tag $tag\n";
148 }
149  
150 0 return;
151 }
152  
153 sub import_project {
154 0 ▶ my ( $self, $dir, $version, $message ) = @_;
Subroutine import_project: not called CC=4 SCAR=30.0
Pod documented
155  
156 0 my $module = $self->module;
157  
158 0 my $tag = $self->gen_tag($version);
159  
160 0 my $tagdir = File::Spec->catdir( $self->tagdir, $module, $tag );
161  
162 0 ▶ if ( !$self->dryrun ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->dryrun) 0 0 0
163 0 ▶ if ( -d $tagdir ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-d $tagdir) 0 0 0
164 0 File::Path::rmtree($tagdir);
165 }
166 0 ▶ File::Copy::Recursive::dircopy( $dir, $tagdir )
Branch: 1 branch
BranchTrueFalseTotal
File::Copy::Recursive::dircopy($dir, $tagdir) or die "Could not import $dir\n" 0 0 0
167 or die "Could not import $dir\n";
168 }
169  
170 0 return;
171 }
172  
173 1 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
174 1 1;
175 __END__
176  
177 =head1 NAME
178  
179 LCFG::Build::VCS::None - LCFG build tools for filesystem based version-control
180  
181 =head1 VERSION
182  
183 This documentation refers to LCFG::Build::VCS::None version 0.2.3
184  
185 =head1 SYNOPSIS
186  
187 my $dir = ".";
188  
189 my $spec = LCFG::Build::PkgSpec->new_from_metafile("$dir/lcfg.yml");
190  
191 my $vcs = LCFG::Build::VCS::None->new( module => $spec->fullname,
192 workdir => $dir );
193  
194 $vcs->genchangelog();
195  
196 if ( $vcs->checkcommitted() ) {
197 $vcs->tagversion();
198 }
199  
200 =head1 DESCRIPTION
201  
202 This is part of a suite of tools designed to provide a standardised
203 interface to version-control systems so that the LCFG build tools can
204 deal with project version-control in a high-level abstract fashion.
205  
206 This module implements the interface specified by
207 L<LCFG::Build::VCS>. It provides support for a really simple
208 filesystem-based version-control system. The working copy can be
209 "tagged" at a particular release with copies of the source tree being
210 made in a tag directory. Support is also provided for exporting these
211 tagged releases. The aim of this module is to provide the minimum
212 necessary to manage the release and build of LCFG packages without
213 requiring a true version-control system such as CVS.
214  
215 More information on the LCFG build tools is available from the website
216 http://www.lcfg.org/doc/buildtools/
217  
218 =head1 ATTRIBUTES
219  
220 =over 4
221  
222 =item module
223  
224 The name of the software package in this repository. This is required
225 and there is no default value.
226  
227 =item workdir
228  
229 The directory in which the commands should be carried out. This is
230 required and if none is specified then it will default to '.', the
231 current working directory. This must be an absolute path but if you
232 pass in a relative path coercion will automatically occur based on the
233 current working directory.
234  
235 =item tagdir
236  
237 This is the directory into which exported 'tags' of the working copy
238 should be placed. If it is not specified then the directory above the
239 specified the working directory will be used. This should be an
240 absolute path, if a relative path is given it will be converted.
241  
242 =item quiet
243  
244 This is a boolean value which controls the quietness of the various
245 methods. By default it is false. This currently does not have much
246 effect on this module but it might in the future.
247  
248 =item dryrun
249  
250 This is a boolean value which controls whether the commands will
251 actually have a real effect or just print out what would be done. By
252 default it is false.
253  
254 =item logname
255  
256 The name of the logfile to which information should be directed when
257 doing version updates. This is also the name of the logfile to be used
258 if you utilise the automatic changelog generation option. The default
259 file name is 'ChangeLog'.
260  
261 =back
262  
263 =head1 SUBROUTINES/METHODS
264  
265 =over 4
266  
267 =item checkcommitted()
268  
269 This is a no-op for simple filesystem-based version control as there
270 is no concept of changes to a file having been committed to a
271 repository.
272  
273 =item genchangelog()
274  
275 This is a no-op for simple filesystem-based version control as there
276 is no revision-control system log from which to generate the logfile.
277  
278 =item tagversion($version)
279  
280 This method is used to tag a set of files for a project at a
281 particular version. The source tree will be copied into a directory
282 named after the tag within the directory specified with the C<tagdir>
283 option. It will also update the changelog appropriately. Tags are
284 generated using the I<gen_tag()> method, see below for details.
285  
286 =item gen_tag($version)
287  
288 Tags are generated from the name and version details passed in by
289 replacing any hyphens or dots with underscores and joining the two
290 fields with an underscore. For example, lcfg-foo and 1.0.1 would
291 become lcfg_foo_1_0_1.
292  
293 =item run_cmd(@args)
294  
295 This is a no-op as the simple filesystem-based version control does
296 not require a separate binary to carry out commands.
297  
298 =item export( $version, $builddir )
299  
300 This will export a particular tagged version of the module. You need
301 to specify the target "build" directory into which the exported tree
302 will be put. The exported tree will be named like
303 "modulename-version". For example:
304  
305 my $vcs = LCFG::Build::VCS::None->new(module => "lcfg-foo");
306 $vcs->export( "1.2.3", "/tmp" );
307  
308 Would give you an exported tree of code for the lcfg-foo module tagged
309 as lcfg_foo_1_2_3 and it would be put into /tmp/lcfg-foo-1.2.3/
310  
311 For the export method to be successful you must have already "tagged"
312 a release using the C<tagversion> method.
313  
314 This method returns the name of the directory into which the tree was
315 exported.
316  
317 =item export_devel( $version, $builddir )
318  
319 This is similar to the export method. It takes the current working
320 tree for a module and exports it directly to another tree based in the
321 specified target "build" directory. For example:
322  
323 my $vcs = LCFG::Build::VCS::None->new(module => "lcfg-foo");
324 $vcs->export_devel( "1.2.3_dev", "/tmp" );
325  
326 Would give you an exported tree of code for the lcfg-foo module
327 directory and it would be put into /tmp/lcfg-foo-1.2.3_dev/
328  
329 This method returns the name of the directory into which the tree was
330 exported.
331  
332 =item logfile()
333  
334 This is a convenience method which returns the full path to the
335 logfile based on the workdir and logname attributes.
336  
337 =item checkout_project()
338  
339 This is not currently supported. You probably want to use the
340 C<export> method instead.
341  
342 =item import_project()
343  
344 This is a no-op as there is no concept of "importing" a project into
345 the simple filesystem-based version control system.
346  
347 =back
348  
349 =head1 DEPENDENCIES
350  
351 This module is L<Moose> powered and it depends on
352 L<LCFG::Build::VCS>. It also requires L<File::Copy::Recursive>
353  
354 =head1 SEE ALSO
355  
356 L<LCFG::Build::PkgSpec>, L<LCFG::Build::VCS::CVS>, L<LCFG::Build::Tools>
357  
358 =head1 PLATFORMS
359  
360 This is the list of platforms on which we have tested this
361 software. We expect this software to work on any Unix-like platform
362 which is supported by Perl.
363  
364 FedoraCore5, FedoraCore6, ScientificLinux5
365  
366 =head1 BUGS AND LIMITATIONS
367  
368 There are no known bugs in this application. Please report any
369 problems to bugs@lcfg.org, feedback and patches are also always very
370 welcome.
371  
372 =head1 AUTHOR
373  
374 Stephen Quinney <squinney@inf.ed.ac.uk>
375  
376 =head1 LICENSE AND COPYRIGHT
377  
378 Copyright (C) 2008 University of Edinburgh. All rights reserved.
379  
380 This library is free software; you can redistribute it and/or modify
381 it under the terms of the GPL, version 2 or later.
382  
383 =cut
« blib/lib/LCFG/Build/VCS.pm ↑ Summary Build »