This repository was archived by the owner on Apr 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 107
Add scripts to insert the MPL notification #237
Open
Meiryo7743
wants to merge
17
commits into
cocoa-mhlw:feature/license_tools
Choose a base branch
from
Meiryo7743:feature/mpl-license-notification-with-git-hooks
base: feature/license_tools
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
251b42e
Add AddLicense.sh
Meiryo7743 e9b2767
Modify AddLicense.sh
Meiryo7743 6ddae8e
Separated processing in AddLicense.sh into two
Meiryo7743 3fc8e5f
Add a script for pre-commit and its installer
Meiryo7743 edfbbfc
Set the repository root as the initial directory
Meiryo7743 6765ccd
Fix source path
Meiryo7743 d375985
Exclude xlf files
Meiryo7743 05b89e5
Modify comment in PreCommit.sh
Meiryo7743 07c5060
Remove `git add` in CheckAllFiles.sh
Meiryo7743 fb4ef2c
Exclude no MPL-licensed file
Meiryo7743 0a01c68
Modify pre-commit
Meiryo7743 1a0c985
Modify CheckAllFiles.sh
Meiryo7743 bacae18
Fix permission
Meiryo7743 8c271c6
Modify comment formats
Meiryo7743 434090c
Modify comment format
Meiryo7743 f172584
Modify AddLicense.sh
Meiryo7743 e27345c
Remove DateTimeUtility.cs from Exclusions.txt
Meiryo7743 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| #!/bin/bash | ||
|
|
||
| # This Source Code Form is subject to the terms of the Mozilla Public | ||
| # License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| # file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
|
||
| function addLicense() { | ||
| local MPL=( | ||
| 'This Source Code Form is subject to the terms of the Mozilla Public' | ||
| 'License, v. 2.0. If a copy of the MPL was not distributed with this' | ||
| 'file, You can obtain one at https://mozilla.org/MPL/2.0/.' | ||
| ) | ||
| local comment='' | ||
| local fileType=${1##*.} | ||
| local lineNumber=1 | ||
|
|
||
| # 各種ファイルに適したコメントを生成する | ||
| if [ "$fileType" == 'axml' ]; then | ||
| comment='\\n'$(printf '<!-- %s\\n - %s\\n - %s -->\\n' "${MPL[@]}") | ||
| lineNumber=2 # XML 宣言の後に挿入する | ||
|
|
||
| elif [ "$fileType" == 'bat' ]; then | ||
| comment=$(printf '@REM %s\\n' "${MPL[@]}") | ||
|
|
||
| elif [ "$fileType" == 'cs' ]; then | ||
| comment=$(printf '/* %s\\n * %s\\n * %s */\\n' "${MPL[@]}") | ||
|
|
||
| elif [ "$fileType" == 'feature' ]; then | ||
| comment=$(printf '# %s\\n' "${MPL[@]}") | ||
|
|
||
| elif [ "$fileType" == 'resx' ]; then | ||
| comment='\\n'$(printf '<!-- %s\\n - %s\\n - %s -->\\n' "${MPL[@]}") | ||
| lineNumber=2 # XML 宣言の後に挿入する | ||
|
|
||
| elif [ "$fileType" == 'sh' ]; then | ||
| comment='\\n'$(printf '# %s\\n' "${MPL[@]}") | ||
| lineNumber=2 # Shebang の後に挿入する | ||
|
|
||
| elif [ "$fileType" == 'storyboard' ]; then | ||
| comment='\\n'$(printf '<!-- %s\\n - %s\\n - %s -->\\n' "${MPL[@]}") | ||
| lineNumber=2 # XML 宣言の後に挿入する | ||
|
|
||
| elif [ "$fileType" == 'strings' ]; then | ||
| comment=$(printf '/* %s\\n * %s\\n * %s */\\n' "${MPL[@]}") | ||
|
|
||
| elif [ "$fileType" == 'tf' ]; then | ||
| comment=$(printf '# %s\\n' "${MPL[@]}") | ||
|
|
||
| elif [ "$fileType" == 'xaml' ]; then | ||
| comment='\\n'$(printf '<!-- %s\\n - %s\\n - %s -->\\n' "${MPL[@]}") | ||
| lineNumber=2 # XML 宣言の後に挿入する | ||
|
|
||
| elif [ "$fileType" == 'xml' ]; then | ||
| comment='\\n'$(printf '<!-- %s\\n - %s\\n - %s -->\\n' "${MPL[@]}") | ||
| lineNumber=2 # XML 宣言の後に挿入する | ||
|
|
||
| elif [ "$fileType" == 'yml' ]; then | ||
| comment=$(printf '# %s\\n' "${MPL[@]}") | ||
| fi | ||
|
|
||
| # MPL の適用対象であるかを確認する。その中でライセンスの文言がないものに限り,生成したコメントを挿入する | ||
| if [ "$comment" != '' ] && [ "$(grep -c "$1" Tools/AddLicense/Exclusions.txt)" -eq 0 ]; then | ||
| git grep -z -I -L "${MPL[0]}" -- "$1" | xargs -0 -r sed -i -e "${lineNumber}i$comment" | ||
| else | ||
| echo "Excluded: $1" | ||
| fi | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| #!/bin/bash | ||
|
|
||
| # This Source Code Form is subject to the terms of the Mozilla Public | ||
| # License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| # file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
|
||
| # リポジトリ内のファイルについて MPL の記載漏れをチェックします。 | ||
| # 詳しい処理につきましては Tools/AddLicense/AddLicense.sh をご参照ください。 | ||
|
|
||
| # リポジトリのルートへ移動 | ||
| cd "$(git rev-parse --show-toplevel)" || exit 1 | ||
|
|
||
| # `addLicense` の読み込み | ||
| source Tools/AddLicense/AddLicense.sh && export -f addLicense | ||
|
|
||
| # 対象ファイル(リポジトリのルートを基準とした相対パスで記述) | ||
| FILES=( | ||
| '*.axml' | ||
| '*.bat' | ||
| '*.cs' | ||
| '*.feature' | ||
| '*.resx' | ||
| '*.sh' | ||
| '*.storyboard' | ||
| '*.strings' | ||
| '*.tf' | ||
| '*.xaml' | ||
| '*.xml' | ||
| '*.yml' | ||
| ) | ||
|
|
||
| # 対象ファイルの内,MPL が抜けているもの対して文言を挿入する | ||
| for file in "${FILES[@]}"; do | ||
| git ls-files -- "$file" | xargs -r -P 4 -I '%' bash -c 'addLicense %' | ||
| done | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| .editorconfig | ||
| .gitattributes | ||
| .github/ISSUE_TEMPLATE/bug_report.md | ||
| .github/ISSUE_TEMPLATE/config.yml | ||
| .github/ISSUE_TEMPLATE/feature_request.md | ||
| .github/PULL_REQUEST_TEMPLATE.md | ||
| .github/workflows/CI.yml | ||
| .gitignore | ||
| CONTRIBUTING.md | ||
| CONTRIBUTORS.md | ||
| Covid19Radar.Functions.runsettings | ||
| Covid19Radar.Functions.sln | ||
| Covid19Radar.sln | ||
| Covid19Radar/Covid19Radar.Android/Assets/AboutAssets.txt | ||
| Covid19Radar/Covid19Radar.Android/Covid19Radar.Android.csproj | ||
| Covid19Radar/Covid19Radar.Android/Resources/AboutResources.txt | ||
| Covid19Radar/Covid19Radar.iOS/Assets.xcassets/AppIcons.appiconset/Contents.json | ||
| Covid19Radar/Covid19Radar.iOS/Assets.xcassets/Contents.json | ||
| Covid19Radar/Covid19Radar.iOS/Covid19Radar.iOS.csproj | ||
| Covid19Radar/Covid19Radar.iOS/Entitlements.plist | ||
| Covid19Radar/Covid19Radar.iOS/Info.plist | ||
| Covid19Radar/Covid19Radar/Covid19Radar.csproj | ||
| Covid19Radar/Covid19Radar/Memo.md | ||
| Covid19Radar/Covid19Radar/Resources/AppResources.Designer.cs | ||
| Covid19Radar/Covid19Radar/Resources/html/en/chatbot2.html | ||
| Covid19Radar/Covid19Radar/Resources/html/en/chatbot3.html | ||
| Covid19Radar/Covid19Radar/Resources/html/en/chatbot4.html | ||
| Covid19Radar/Covid19Radar/Resources/html/en/chatbot5.html | ||
| Covid19Radar/Covid19Radar/Resources/html/en/css/style.css | ||
| Covid19Radar/Covid19Radar/Resources/html/en/index.html | ||
| Covid19Radar/Covid19Radar/Resources/html/en/privacypolicy.html | ||
| Covid19Radar/Covid19Radar/Resources/html/en/privacypolicy.md | ||
| Covid19Radar/Covid19Radar/Resources/html/en/termofuse.html | ||
| Covid19Radar/Covid19Radar/Resources/html/en/termofuse.md | ||
| Covid19Radar/Covid19Radar/Resources/html/index.html | ||
| Covid19Radar/Covid19Radar/Resources/html/ja/chatbot2.html | ||
| Covid19Radar/Covid19Radar/Resources/html/ja/chatbot3.html | ||
| Covid19Radar/Covid19Radar/Resources/html/ja/chatbot4.html | ||
| Covid19Radar/Covid19Radar/Resources/html/ja/chatbot5.html | ||
| Covid19Radar/Covid19Radar/Resources/html/ja/css/style.css | ||
| Covid19Radar/Covid19Radar/Resources/html/ja/index.html | ||
| Covid19Radar/Covid19Radar/Resources/html/ja/privacypolicy.html | ||
| Covid19Radar/Covid19Radar/Resources/html/ja/privacypolicy.md | ||
| Covid19Radar/Covid19Radar/Resources/html/ja/termofuse.html | ||
| Covid19Radar/Covid19Radar/Resources/html/ja/termofuse.md | ||
| Covid19Radar/Covid19Radar/Resources/html/zh-hans/chatbot2.html | ||
| Covid19Radar/Covid19Radar/Resources/html/zh-hans/chatbot3.html | ||
| Covid19Radar/Covid19Radar/Resources/html/zh-hans/chatbot4.html | ||
| Covid19Radar/Covid19Radar/Resources/html/zh-hans/chatbot5.html | ||
| Covid19Radar/Covid19Radar/Resources/html/zh-hans/css/style.css | ||
| Covid19Radar/Covid19Radar/Resources/html/zh-hans/index.html | ||
| Covid19Radar/Covid19Radar/Resources/html/zh-hans/privacypolicy.html | ||
| Covid19Radar/Covid19Radar/Resources/html/zh-hans/privacypolicy.md | ||
| Covid19Radar/Covid19Radar/Resources/html/zh-hans/termofuse.html | ||
| Covid19Radar/Covid19Radar/Resources/html/zh-hans/termofuse.md | ||
| Covid19Radar/Covid19Radar/settings.json | ||
| Covid19Radar/Tests/Covid19Radar.UITest/App.config | ||
| Covid19Radar/Tests/Covid19Radar.UITest/Covid19Radar.UITest.csproj | ||
| Covid19Radar/Tests/Covid19Radar.UITest/Features/HomePage/ContributorsList.feature.cs | ||
| Covid19Radar/Tests/Covid19Radar.UITest/Features/HomePage/Home.feature.cs | ||
| Covid19Radar/Tests/Covid19Radar.UITest/Features/HomePage/LicenseAgreement.feature.cs | ||
| Covid19Radar/Tests/Covid19Radar.UITest/Features/HomePage/UpdateInformation.feature.cs | ||
| Covid19Radar/Tests/Covid19Radar.UITest/Features/Tutorial/Tutorial.feature.cs | ||
| Covid19Radar/Tests/Covid19Radar.UITest/ReadMe.txt | ||
| Covid19Radar/Tests/Covid19Radar.UITest/TestConfig.json | ||
| Covid19Radar/Tests/Covid19Radar.UnitTests/Covid19Radar.UnitTests.csproj | ||
| Covid19Radar/Xamarin.ExposureNotification/CallbackService.android.cs | ||
| Covid19Radar/Xamarin.ExposureNotification/ExposureInfo.shared.cs | ||
| Covid19Radar/Xamarin.ExposureNotification/ExposureNotification.android.cs | ||
| Covid19Radar/Xamarin.ExposureNotification/ExposureNotification.customize.android.cs | ||
| Covid19Radar/Xamarin.ExposureNotification/ExposureNotification.ios.cs | ||
| Covid19Radar/Xamarin.ExposureNotification/ExposureNotification.netstandard.cs | ||
| Covid19Radar/Xamarin.ExposureNotification/ExposureNotification.shared.cs | ||
| Covid19Radar/Xamarin.ExposureNotification/IExposureNotificationHandler.shared.cs | ||
| Covid19Radar/Xamarin.ExposureNotification/TemporaryExposureKey.shared.cs | ||
| Covid19Radar/Xamarin.ExposureNotification/Xamarin.ExposureNotification.csproj | ||
| OPERATION_POLICY.md | ||
| README.ja.md | ||
| README.md | ||
| Tools/ConvertBase64/ConvertBase64.sln | ||
| Tools/ConvertBase64/ConvertBase64/ConvertBase64.csproj | ||
| Tools/GenerateKeys/GenerateKeys.sln | ||
| Tools/GenerateKeys/GenerateKeys/GenerateKeys.csproj | ||
| Tools/UpdateUserStatusTool/UpdateUserStatusTool.sln | ||
| Tools/UpdateUserStatusTool/UpdateUserStatusTool/App.config.example | ||
| Tools/UpdateUserStatusTool/UpdateUserStatusTool/Properties/launchSettings.json | ||
| Tools/UpdateUserStatusTool/UpdateUserStatusTool/UpdateUserStatusTool.csproj | ||
| infrastructure/01_init/Readme.md | ||
| infrastructure/02_runtime/Readme.md | ||
| infrastructure/Readme.md | ||
| src/Covid19Radar.Api.Common/Covid19Radar.Api.Common.csproj | ||
| src/Covid19Radar.Api.External/Covid19Radar.Api.External.csproj | ||
| src/Covid19Radar.Api.External/host.json | ||
| src/Covid19Radar.Api.External/local.settings.json.example | ||
| src/Covid19Radar.Api.Tests/Covid19Radar.Api.Tests.csproj | ||
| src/Covid19Radar.Api/Covid19Radar.Api.csproj | ||
| src/Covid19Radar.Api/host.json | ||
| src/Covid19Radar.Api/local.settings.json.example | ||
| src/Covid19Radar.Background/Covid19Radar.Background.csproj | ||
| src/Covid19Radar.Background/Protobuf/TemporaryExposureKeyExportFileFormat.proto | ||
| src/Covid19Radar.Background/host.json | ||
| src/Covid19Radar.Background/local.settings.json.example |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| #!/bin/bash | ||
|
|
||
| # This Source Code Form is subject to the terms of the Mozilla Public | ||
| # License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| # file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
|
||
| # Commit 時に MPL の記載漏れをチェックします。 | ||
| # あらかじめ Tools/GitHooks/PrepareHooks.sh を実行する必要があります。 | ||
| # 詳しい処理につきましては Tools/AddLicense/AddLicense.sh をご参照ください。 | ||
|
|
||
| # リポジトリのルートへ移動 | ||
| cd "$(git rev-parse --show-toplevel)" || exit 1 | ||
|
|
||
| # `addLicense` の読み込み | ||
| source Tools/AddLicense/AddLicense.sh | ||
|
|
||
| # ステージングエリアのファイル一覧を取得(削除を除く) | ||
| stagedFiles=$(git diff --name-only --cached --diff-filter=d) | ||
|
|
||
| # 対象ファイルの内,MPL が抜けているもの対して文言を挿入する | ||
| for file in $stagedFiles; do | ||
| addLicense "$file" && git add "$file" | ||
| done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| #!/bin/bash | ||
|
|
||
| # This Source Code Form is subject to the terms of the Mozilla Public | ||
| # License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| # file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
|
||
| # リポジトリのルートへ移動 | ||
| cd "$(git rev-parse --show-toplevel)" || exit 1 | ||
|
|
||
| # pre-commit 用のスクリプトを追加 | ||
| install -m 755 -D Tools/GitHooks/PreCommit.sh .git/hooks/pre-commit | ||
|
|
||
| # 追加した Git Hooks を有効にする | ||
| git init |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.