|
This is a very simple perl script that adds entries to the .cvsignore file. I find it useful, as before adding a project to CVS using Eclipse, I walk through my directory structure and on the fly add things to .cvsignore.
-
#!/usr/bin/perl -w
-
############################################
-
#
-
# Add files to the .cvsignore file.
-
#
-
############################################
-
# The file .cvsignore is created if not yet
-
# there. The entries are sorted. If an entry
-
# is already there, it is not added again.
-
#
-
# You can use stdin like
-
#
-
# ls -1 *.class | cvsignore
-
#
-
# or you can pass command line parameters
-
#
-
# cvsignore *.class
-
#
-
# If the parameter is "-d", the entry is de-
-
# leted;
-
#
-
# cvsignore -d *.class
-
#
-
# The -d can be passed at any place in the
-
# command line:
-
#
-
# cvsignore *.java -d *.class
-
#
-
# Once you passed -d, the rest of the line
-
# will be deleted until the next -d.
-
#
-
# -d cannot be used together with stdin.
-
#
-
############################################
-
# (C) 2006 MN Soft Industry Software
-
#############################################
-
-
use strict;
-
-
my @cvsignore;
-
my %cvskeys;
-
my $op = 1; # -1 to delete
-
-
if(-f ".cvsignore") {
-
open(CVS, ".cvsignore") || die "Cannot open: $!\n";
-
while(<CVS>) {
-
-
$cvskeys{$_} = "";
-
}
-
-
}
-
-
-
for (@ARGV) {
-
-
$op = -$op;
-
next;
-
}
-
if($op == 1) {
-
addKey($_);
-
} else {
-
deleteKey($_);
-
}
-
}
-
} else {
-
while(<>) {
-
addKey($_);
-
}
-
}
-
-
open(CVS, ">.cvsignore") || die "Cannot open: $!\n";
-
-
-
}
-
-
-
#
-
# Add an entry to .cvsignore
-
#
-
sub addKey {
-
-
if (/^(.*)\/$/) {
-
$_ = $1;
-
}
-
-
print ".cvsignore: contained already: $_\n";
-
} else {
-
print ".cvsignore: added a new entry: $_\n";
-
$cvskeys{$_} = "";
-
}
-
}
-
-
#
-
# Delete an entry from .cvsignore
-
#
-
sub deleteKey {
-
-
if (/^(.*)\/$/) {
-
$_ = $1;
-
}
-
-
print ".cvsignore: deleted the entry: $_\n";
-
-
}
-
}
Sample call (more detailed examples are in the comments above):
-
linux:/pgm/java/CPEclipseCP # ls -la
-
total 38
-
drwxr-xr-x 6 mnott users 328 Oct 8 2004 ./
-
drwxr-xr-x 29 mnott users 1856 Jan 11 15:35 ../
-
-rw-r--r-- 1 mnott users 495 Jan 18 2005 .classpath
-
-rw-r--r-- 1 mnott users 370 Oct 8 2004 .project
-
-rwx------ 1 mnott users 11560 Oct 8 2004 LICENSE.txt*
-
drwxr-xr-x 3 mnott users 72 Jun 29 2005 bin/
-
-rw-r--r-- 1 mnott users 6686 Jan 18 2005 build.xml
-
drwxr-xr-x 3 mnott users 80 Oct 8 2004 distribution/
-
drwx------ 3 mnott users 352 Oct 8 2004 helpers/
-
-rwxr-xr-x 1 mnott users 417 Oct 8 2004 make.sh*
-
-rw-r--r-- 1 mnott users 1457 Oct 8 2004 overview.html
-
drwxr-xr-x 3 mnott users 72 Oct 8 2004 src/
-
linux:/pgm/java/CPEclipseCP # cvsignore LICENSE.txt bin/ distribution/ helpers/
-
.cvsignore: added a new entry: LICENSE.txt
-
.cvsignore: added a new entry: bin
-
.cvsignore: added a new entry: distribution
-
.cvsignore: added a new entry: helpers
-
linux:/pgm/java/CPEclipseCP # cat .cvsignore
-
LICENSE.txt
-
bin
-
distribution
-
helpers
-
linux:/pgm/java/CPEclipseCP # cvsignore LICENSE.txt bin/ distribution/
-
.cvsignore: contained already: LICENSE.txt
-
.cvsignore: contained already: bin
-
.cvsignore: contained already: distribution
-
linux:/pgm/java/CPEclipseCP #
-
|