Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
Signed-off-by: Simon L. <szaimen@e.mail.de>
  • Loading branch information
szaimen committed Oct 14, 2024
1 parent f838cde commit 5ae8f4e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
24 changes: 13 additions & 11 deletions .build/license.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function exec($folder, $gitRoot = false) {

$excludes = array_map(function ($item) use ($folder) {
return $folder . '/' . $item;
}, ['vendor', '3rdparty', '.git', 'l10n', 'templates', 'composer', 'js', 'node_modules']);
}, ['vendor', '3rdparty', '.git', 'l10n', 'composer', 'js', 'node_modules']);

$iterator = new RecursiveDirectoryIterator($folder, RecursiveDirectoryIterator::SKIP_DOTS);
$iterator = new RecursiveCallbackFilterIterator($iterator, function ($item) use ($folder, $excludes) {
Expand All @@ -97,7 +97,7 @@ public function exec($folder, $gitRoot = false) {
return true;
});
$iterator = new RecursiveIteratorIterator($iterator);
$iterator = new RegexIterator($iterator, '/^.+\.(js|php)$/i');
$iterator = new RegexIterator($iterator, '/^.+\.(js|php|md|twig|xml|json|Dockerfile|Caddyfile|sh|conf|script|cfg|motd|yml|yaml|gitkeep|svg|txt|css|lock)$/i');

foreach ($iterator as $file) {
/** @var SplFileInfo $file */
Expand All @@ -109,14 +109,13 @@ public function exec($folder, $gitRoot = false) {

public function writeAuthorsFile() {
ksort($this->authors);
$template = 'Nextcloud is written by:
$template = '<!--
- SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
- SPDX-License-Identifier: AGPL-3.0-or-later
-->
# Authors
@AUTHORS@
With help from many libraries and frameworks including:
Open Collaboration Services
SabreDAV
jQuery
';
$authors = implode(PHP_EOL, array_map(function ($author) {
return ' - ' . $author;
Expand All @@ -127,6 +126,7 @@ public function writeAuthorsFile() {

public function handleFile($path, $gitRoot) {
$isPhp = preg_match('/^.+\.php$/i', $path);
$isMd = preg_match('/^.+\.md$/i', $path);

$source = file_get_contents($path);
if ($this->isMITLicensed($source)) {
Expand Down Expand Up @@ -157,9 +157,11 @@ public function handleFile($path, $gitRoot) {
} else {
$source = '<?php' . PHP_EOL . $license . PHP_EOL . $source;
}
} else {
$source = $license . PHP_EOL . PHP_EOL . $source;
}
} else if ($isMd) {
$source = '<!--' . PHP_EOL . $license . PHP_EOL . '-->' . PHP_EOL . PHP_EOL . $source;
} else {
$source = $license . PHP_EOL . PHP_EOL . $source;
}

file_put_contents($path, $source);
echo "License updated: $path" . PHP_EOL;
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/update-copyright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ jobs:
set -x
cd .build
php license.php
cd ../
cd ../
- uses: actions/checkout@v4
with:
repository: nextcloud/github_helper
ref: master

- name: Run script
run: |
set -x
ls -la
php github_helper/spdx-convertor/convert.php ./all-in-one
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
Expand Down

0 comments on commit 5ae8f4e

Please sign in to comment.