]> source.dussan.org Git - nextcloud-server.git/commitdiff
detect MIT licensed files and ignore them for now
authorThomas Müller <thomas.mueller@tmit.eu>
Tue, 17 Mar 2015 10:58:46 +0000 (11:58 +0100)
committerThomas Müller <thomas.mueller@tmit.eu>
Thu, 26 Mar 2015 10:38:40 +0000 (11:38 +0100)
build/license.php

index f7fd52d3977649c16028e1c15c1b1e20e41d9026..a8d82b084e6054883dcb12f98c358fa076d3305c 100644 (file)
@@ -87,13 +87,30 @@ EOD;
 
        function handleFile($path) {
                $source = file_get_contents($path);
+               if ($this->isMITLicensed($source)) {
+                       echo "MIT licensed file: $path" . PHP_EOL;
+                       return;
+               }
                $source = $this->eatOldLicense($source);
                $authors = $this->getAuthors($path);
                $license = str_replace('@AUTHORS@', $authors, $this->licenseText);
 
                $source = "<?php" . PHP_EOL . $license . PHP_EOL . $source;
                file_put_contents($path,$source);
-               echo "License updated: $path\n";
+               echo "License updated: $path" . PHP_EOL;
+       }
+
+       private function isMITLicensed($source) {
+               $lines = explode(PHP_EOL, $source);
+               while(!empty($lines)) {
+                       $line = $lines[0];
+                       array_shift($lines);
+                       if (strpos($line, 'The MIT License') !== false) {
+                               return true;
+                       }
+               }
+
+               return false;
        }
 
        private function eatOldLicense($source) {