Skip to content

Instantly share code, notes, and snippets.

@plu
Created November 25, 2010 08:32
Show Gist options
  • Save plu/715088 to your computer and use it in GitHub Desktop.
Save plu/715088 to your computer and use it in GitHub Desktop.
commit 7950a090117bcf2e630f9c2f5272e858decb84ce
Author: Johannes Plunien <johannes.plunien@xing.com>
Date: Thu Nov 25 09:30:42 2010 +0100
Let fcopy look for files containing more than one class name separated by dots.
diff --git a/bin/fcopy b/bin/fcopy
index 93bd7db..0eaa0c5 100755
--- a/bin/fcopy
+++ b/bin/fcopy
@@ -95,6 +95,28 @@ sub copy_one {
my $backupfile = $backupdir ? "$backupdir/$source" : "$destfile.pre_fcopy";
my $bpath = dirname $backupfile;
+ # Let's see if we can find another file there which looks like CLASS1.CLASS2.CLASSn
+ # All parts of the filename must be separated by dots and be valid FAI classes. If
+ # a server is part of -all- classes found in the filename, it will be used. Please
+ # be careful since this is the -last- hit. This means if you have some files called
+ # PERL, APP and one called APP.PERL the one named APP.PERL will be chosen over the
+ # other two! It will always select the most specific class. If there is a file
+ # APP.PERL.HUDSON, this will chosen over APP, PERL and even APP.PERL.
+ my $ident_weight = 0;
+ foreach my $item (glob("$ps/*")) {
+ $item = basename $item;
+ next unless $item =~ /\./;
+ my @parts = split /\./, $item;
+ my $ident = 0;
+ foreach my $part (@parts) {
+ $ident++ if grep $_ eq $part, @classes;
+ }
+ if ($ident == scalar @parts && $ident_weight < scalar @parts) {
+ $class = $item;
+ $ident_weight = scalar @parts;
+ }
+ }
+
unless (defined $class) {
ewarn("no matching file for any class for $source defined.");
# do not copy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment