App-GitFind
view release on metacpan or search on metacpan
Long elements (e.g., "-name") can start with a single or a double dash.
Tests are of two types:
Index tests
These are tests that only require information from the git index, such
as the name of the file and whether it is executable. They are (at
least on Unix-like systems):
"-cmin", "-cnewer", "-ctime", "-empty", "-executable", "-false",
"-gid", "-group", "-ilname", "-iname", "-inum", "-ipath", "-iregex",
"-iwholename", "-level", "-mmin", "-mtime", "-name", "-nogroup",
"-nouser", "-path", "-readable", "-regex", "-size", "-true", "-type",
"-uid", "-user", "-wholename", "-writeable"
TODO also -links, -lname, -perm, -samefile, -xtype?
Detailed tests
All tests other than index tests may require checking out a worktree
with one or more of the given revs. Therefore, they may be much
slower than name-only tests. However, if the only rev given is "]]"
Long elements (e.g., `-name`) can start with a single or a double dash.
Tests are of two types:
- Index tests
These are tests that only require information from the git index, such
as the name of the file and whether it is executable. They are (at least on
Unix-like systems):
`-cmin`, `-cnewer`, `-ctime`, `-empty`, `-executable`, `-false`, `-gid`,
`-group`, `-ilname`, `-iname`, `-inum`, `-ipath`, `-iregex`,
`-iwholename`, `-level`, `-mmin`, `-mtime`, `-name`, `-nogroup`,
`-nouser`, `-path`, `-readable`, `-regex`, `-size`, `-true`, `-type`,
`-uid`, `-user`, `-wholename`, `-writeable`
TODO also -links, -lname, -perm, -samefile, -xtype?
- Detailed tests
All tests other than index tests may require
lib/App/GitFind/Actions.pm view on Meta::CPAN
# No-argument tests -- all happen to be index tests
map( { _t $_, 0, true }
qw(empty executable false nogroup nouser readable true writeable) ),
# No-argument actions
map( { _a $_ } qw(delete ls print print0 prune quit) ),
# One-argument index tests
map( { _t $_, 1, true } qw(
cmin cnewer ctime
gid group ilname iname inum ipath iregex iwholename level
mmin mtime name
path
regex
size type uid
user wholename
) ),
# One-argument detailed tests
map( { _t $_, 1 } _qwc <<'EOT' ),
amin anewer atime fstype
lib/App/GitFind/Actions.pm view on Meta::CPAN
map( { _t('newer' . join('', @$_), 1) }
cartesian {1} [qw(a B c m)], [qw(a B c m t)] ),
# -amin n
# -anewer file
# -atime n
# -cmin n
# -cnewer file
# -ctime n
# -fstype type
# -gid n
# -group gname
# -ilname pattern
# -iname pattern
# -inum n
# -ipath pattern
# -iregex pattern
# -iwholename pattern
# -level n # not in find(1) - succeed if the item is at level n
# -links n
# -lname pattern
lib/App/GitFind/Entry.pm view on Meta::CPAN
# This is a lazy initializer so we don't stat() if we don't have to.
_lstat => sub { ... },
# Returns an arrayref of lstat() results. Must be overriden in
# subclasses unless the below uses of _lstat are overridden.
dev => sub { $_[0]->_lstat->[0] }, # device number of filesystem
ino => sub { $_[0]->_lstat->[1] }, # inode number
mode => sub { $_[0]->_lstat->[2] }, # file mode (type and permissions)
nlink => sub { $_[0]->_lstat->[3] }, # number of (hard) links to the file
uid => sub { $_[0]->_lstat->[4] }, # numeric user ID of file's owner
gid => sub { $_[0]->_lstat->[5] }, # numeric group ID of file's owner
rdev => sub { $_[0]->_lstat->[6] }, # the device identifier (special files only)
size => sub { $_[0]->_lstat->[7] }, # total size of file, in bytes
atime => sub { $_[0]->_lstat->[8] }, # last access time in seconds since the epoch
mtime => sub { $_[0]->_lstat->[9] }, # last modify time in seconds since the epoch
ctime => sub { $_[0]->_lstat->[10] }, # inode change time in seconds since the epoch (*)
blksize => sub { $_[0]->_lstat->[11] }, # preferred I/O size in bytes for interacting with the file (may vary from file to file)
blocks => sub { $_[0]->_lstat->[12] }, # actual number of system-specific blocks allocated
};
# Docs {{{1
lib/App/GitFind/FileStatLs.pm view on Meta::CPAN
my @permstrs = @perms[($mode&0700)>>6, ($mode&0070)>>3, $mode&0007];
my $ftype = $ftype[($mode & 0170000)>>12];
if ($setids) {
if ($setids & 01) { # Sticky bit
$permstrs[2] =~ s/([-x])$/$1 eq 'x' ? 't' : 'T'/e;
}
if ($setids & 04) { # Setuid bit
$permstrs[0] =~ s/([-x])$/$1 eq 'x' ? 's' : 'S'/e;
}
if ($setids & 02) { # Setgid bit
$permstrs[1] =~ s/([-x])$/$1 eq 'x' ? 's' : 'S'/e;
}
}
join '', $ftype, @permstrs;
}
=head2 ls_stat ($fn)
Input variables:
lib/App/GitFind/FileStatLs.pm view on Meta::CPAN
-r-xr-xr-x 1 root other 4523 Jul 12 09:49 uniq
drwxr-xr-x 2 root other 2048 Jul 12 09:50 bin
lrwxrwxrwx 1 oracle7 dba 40 Jun 12 2002 linked.pl -> /opt/bin/linked2.pl
The output B<includes> a trailing newline.
=cut
sub ls_stat {
my $fn = shift;
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks) = lstat $fn;
my $dft = "%b %d %Y";
my $ud = getpwuid($uid);
my $gd = getgrgid($gid);
my $fm = format_mode($mode);
my $mt = strftime $dft,localtime $mtime;
my $link_to = (($mode & S_IFLNK) == S_IFLNK ? " -> @{[readlink $fn]}" : "");
my $fmt = "%10s %3d %7s %4s %12d %12s %-s%s\n";
return sprintf $fmt, $fm,$nlink,$ud,$gd,$size,$mt,$fn,$link_to;
}
=head2 stat_attr ($fn, $typ)
Input variables:
$fn - file name for getting stat attributes
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks) = stat($fn);
$typ - what type of object that you want it to return.
The default is to return a hash containing filename, longname,
and a hash ref with all the element from stat.
SFTP - to return a Net::SFTP::Attributes object
Variables used or routines called:
ls_stat
lib/App/GitFind/FileStatLs.pm view on Meta::CPAN
my $hr = $self->stat_attr($fn); # get hash ref
my %h = $self->stat_attr($fn); # get hash
Return: C<$hr> or C<%h> where the hash elements depend on the type.
The default is to get a hash array with the following elements:
filename - file name
longname - the ls_stat string for the file
a - the attributes of the file with the following elements:
dev,ino,mode,nlink,uid,gid,rdev,size,atime,mtime,
ctime,blksize,blocks
If the type is SFTP, then it will only return a
L<Net::SFTP::Attributes> object with the following elements:
flags,perm,uid,gid,size,atime,mtime
=cut
sub stat_attr {
my $s = ref($_[0]) ? shift : (App::GitFind::FileStatLs->new);
my ($fn,$typ) = @_;
(require Carp, Carp::croak "ERR: no file name for stat_attr.\n") if ! $fn;
return undef if ! $fn;
my $vs = 'dev,ino,mode,nlink,uid,gid,rdev,size,atime,mtime,';
$vs .= 'ctime,blksize,blocks';
my $v1 = 'flags,perm,uid,gid,size,atime,mtime';
my $ls = ls_stat $fn; chomp $ls;
my @a = (); my @v = ();
my $attr = {};
if ($typ && $typ =~ /SFTP/i) {
@v = split /,/, $v1;
@a = (stat($fn))[1,2,4,5,7,8,9];
%$attr = map { $v[$_] => $a[$_] } 0..$#a ;
# 'SSH2_FILEXFER_ATTR_SIZE' => 0x01,
# 'SSH2_FILEXFER_ATTR_UIDGID' => 0x02,
# 'SSH2_FILEXFER_ATTR_PERMISSIONS' => 0x04,
script/git-find view on Meta::CPAN
Tests are of two types:
=over
=item Index tests
These are tests that only require information from the git index, such
as the name of the file and whether it is executable. They are (at least on
Unix-like systems):
C<-cmin>, C<-cnewer>, C<-ctime>, C<-empty>, C<-executable>, C<-false>, C<-gid>,
C<-group>, C<-ilname>, C<-iname>, C<-inum>, C<-ipath>, C<-iregex>,
C<-iwholename>, C<-level>, C<-mmin>, C<-mtime>, C<-name>, C<-nogroup>,
C<-nouser>, C<-path>, C<-readable>, C<-regex>, C<-size>, C<-true>, C<-type>,
C<-uid>, C<-user>, C<-wholename>, C<-writeable>
TODO also -links, -lname, -perm, -samefile, -xtype?
=item Detailed tests
All tests other than index tests may require
( run in 1.473 second using v1.01-cache-2.11-cpan-ceb78f64989 )