From 24cb82d4dc778627a3db8881a002db929fd15b70 Mon Sep 17 00:00:00 2001 From: Tillmann Karras Date: Sat, 23 May 2015 08:45:40 +0200 Subject: [PATCH] Tools: add script for updating license headers --- Tools/update-license-headers.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 Tools/update-license-headers.sh diff --git a/Tools/update-license-headers.sh b/Tools/update-license-headers.sh new file mode 100755 index 0000000000..8e0581b4c5 --- /dev/null +++ b/Tools/update-license-headers.sh @@ -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