Ejemplo n.º 1
0
            if (trim($line) === '') {
                array_shift($lines);
                continue;
            }
            break;
        }
        return implode(PHP_EOL, $lines);
    }
    private function getAuthors($file)
    {
        // only add authors that changed code and not the license header
        $licenseHeaderEndsAtLine = trim(shell_exec("grep -n '*/' {$file} | head -n 1 | cut -d ':' -f 1"));
        $out = shell_exec("git blame --line-porcelain -L {$licenseHeaderEndsAtLine}, {$file} | sed -n 's/^author //p;s/^author-mail //p' | sed 'N;s/\\n/ /' | sort -f | uniq");
        $authors = explode(PHP_EOL, $out);
        $authors = array_filter($authors, function ($author) {
            return !in_array($author, ['', 'Not Committed Yet <not.committed.yet>', 'Jenkins for ownCloud <*****@*****.**>']);
        });
        $authors = array_map(function ($author) {
            $this->authors[$author] = $author;
            return " * @author {$author}";
        }, $authors);
        return implode(PHP_EOL, $authors);
    }
}
$licenses = new Licenses();
if (isset($argv[1])) {
    $licenses->exec($argv[1]);
} else {
    $licenses->exec(['../apps/dav', '../apps/encryption', '../apps/federation', '../apps/files', '../apps/files_external', '../apps/files_sharing', '../apps/files_trashbin', '../apps/files_versions', '../apps/provisioning_api', '../apps/user_ldap', '../core', '../lib', '../ocs', '../settings', '../console.php', '../cron.php', '../index.php', '../public.php', '../remote.php', '../status.php', '../version.php']);
    $licenses->writeAuthorsFile();
}