Browse Source
[license-header] refactor: excludes, updating, better logic (#2780)
[license-header] refactor: excludes, updating, better logic (#2780)
Rewrite of license-header.sh. Lots of new goodies: - Fully POSIX compliant - supports dash arguments (-u/--update, -c/--commit, -uc for both) - can update year or malformed headers in-place now - accounts for shell scripts - exclusion of external files (e.g. sse2neon, my CMake modules/scripts) - better, more extensible logic all around Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/2780pull/2794/head
No known key found for this signature in database
GPG Key ID: 425ACD2D4830EBC6
6 changed files with 202 additions and 146 deletions
-
47.ci/license-header.rb
-
289.ci/license-header.sh
-
2.ci/license/header-hash.txt
-
2.ci/license/header.txt
-
8docs/Development.md
-
0tools/cpm-fetch-all.sh
@ -1,47 +0,0 @@ |
|||||
#!/usr/bin/ruby |
|
||||
# frozen_string_literal: true |
|
||||
|
|
||||
license_header = <<~EOF |
|
||||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project |
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later |
|
||||
EOF |
|
||||
|
|
||||
print 'Getting branch changes...' |
|
||||
branch_name = `git rev-parse --abbrev-ref HEAD`.chomp |
|
||||
branch_commits = `git log #{branch_name} --not master --pretty=format:"%h"`.split("\n") |
|
||||
branch_commit_range = "#{branch_commits[-1]}^..#{branch_commits[0]}" |
|
||||
branch_changed_files = `git diff-tree --no-commit-id --name-only #{branch_commit_range} -r`.split("\n") |
|
||||
puts 'done' |
|
||||
|
|
||||
print 'Checking files...' |
|
||||
issue_files = [] |
|
||||
branch_changed_files.each do |file_name| |
|
||||
if file_name.end_with?('.cpp', '.h', '.kt', '.kts') and File.file?(file_name) |
|
||||
file_content = File.read(file_name) |
|
||||
if not file_content.start_with?(license_header) |
|
||||
issue_files.push(file_name) |
|
||||
end |
|
||||
end |
|
||||
end |
|
||||
puts 'done' |
|
||||
|
|
||||
if issue_files.empty? |
|
||||
puts "\nAll changed files have correct headers" |
|
||||
exit 0 |
|
||||
end |
|
||||
|
|
||||
puts <<-EOF |
|
||||
|
|
||||
The following #{issue_files.length} files have incorrect license headers: |
|
||||
#{issue_files.join("\n")} |
|
||||
|
|
||||
The following license header should be added to the start of all offending files: |
|
||||
=== BEGIN === |
|
||||
#{license_header} |
|
||||
=== END === |
|
||||
|
|
||||
If some of the code in this PR is not being contributed by the original author, the files which have been exclusively changed by that code can be ignored. |
|
||||
If this happens, this PR requirement can be bypassed once all other files are addressed. |
|
||||
EOF |
|
||||
|
|
||||
exit 1 |
|
||||
@ -1,2 +0,0 @@ |
|||||
# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project |
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later |
|
||||
@ -1,2 +0,0 @@ |
|||||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project |
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later |
|
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue