mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 05:17:44 -07:00
Tools: add script for updating license headers
This commit is contained in:
parent
cefcb0ace9
commit
24cb82d4dc
15
Tools/update-license-headers.sh
Executable file
15
Tools/update-license-headers.sh
Executable file
@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
# Updates a file's license header to the first year a commit touched it.
|
||||
# Example: find -name \*.cpp -o -name \*.h|xargs -n1 -P8 /path/to/Tools/update-license-headers.sh
|
||||
|
||||
filename=$1
|
||||
echo "Updating $filename..."
|
||||
year=$(git log --diff-filter=A --follow --format=%ad --date=short "$1"|tail -n1|cut -d- -f1)
|
||||
if [[ "$(head -n1 "$filename" | grep Copyright)" == "" ]]
|
||||
then
|
||||
tmp="$(mktemp)"
|
||||
echo -e "// Copyright $year Dolphin Emulator Project\n// Licensed under GPLv2+\n// Refer to the license.txt file included.\n"|cat - "$filename" >"$tmp"
|
||||
mv "$tmp" "$filename"
|
||||
else
|
||||
sed -ri "1 s|// Copyright ([0-9-]+) Dolphin Emulator Project|// Copyright $year Dolphin Emulator Project|" "$filename"
|
||||
fi
|
Loading…
Reference in New Issue
Block a user