From b23950281386ae24075e518f883224b868c2e87f Mon Sep 17 00:00:00 2001 From: Evan Hahn <69474926+EvanHahn-Signal@users.noreply.github.com> Date: Fri, 1 Oct 2021 16:52:36 -0500 Subject: [PATCH] Fix license header file enumeration --- .github/ISSUE_TEMPLATE/config.yml | 3 ++ .github/stale.yml | 3 ++ .github/workflows/backport.yml | 1 - aptly.sh | 1 - preload_test.js | 3 ++ stylesheets/components/CompositionArea.scss | 3 ++ stylesheets/components/Input.scss | 3 ++ stylesheets/components/LeftPaneDialog.scss | 3 ++ ts/test-node/license_comments_test.ts | 13 +++++++-- ts/util/lint/license_comments.ts | 31 +++++++++++++++------ 10 files changed, 51 insertions(+), 13 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 09613c707..2956bdba5 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,3 +1,6 @@ +# Copyright 2021 Signal Messenger, LLC +# SPDX-License-Identifier: AGPL-3.0-only + blank_issues_enabled: false contact_links: - name: ✨ Feature request diff --git a/.github/stale.yml b/.github/stale.yml index 024c9fecb..9c37ad9c9 100644 --- a/.github/stale.yml +++ b/.github/stale.yml @@ -1,3 +1,6 @@ +# Copyright 2021 Signal Messenger, LLC +# SPDX-License-Identifier: AGPL-3.0-only + # Configuration for probot-stale - https://github.com/probot/stale # Number of days of inactivity before an Issue or Pull Request becomes stale diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index 8543b9321..8e1206af6 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -1,4 +1,3 @@ - # Copyright 2021 Signal Messenger, LLC # SPDX-License-Identifier: AGPL-3.0-only diff --git a/aptly.sh b/aptly.sh index 290a01885..072a4eb6d 100755 --- a/aptly.sh +++ b/aptly.sh @@ -1,5 +1,4 @@ #!/bin/bash - # Copyright 2017-2021 Signal Messenger, LLC # SPDX-License-Identifier: AGPL-3.0-only diff --git a/preload_test.js b/preload_test.js index 2aca6f16c..0c8c6e856 100644 --- a/preload_test.js +++ b/preload_test.js @@ -1,3 +1,6 @@ +// Copyright 2021 Signal Messenger, LLC +// SPDX-License-Identifier: AGPL-3.0-only + /* global window */ // This is a hack to let us run TypeScript tests in the renderer process. See the diff --git a/stylesheets/components/CompositionArea.scss b/stylesheets/components/CompositionArea.scss index 93f5cfedb..1abdc3b01 100644 --- a/stylesheets/components/CompositionArea.scss +++ b/stylesheets/components/CompositionArea.scss @@ -1,3 +1,6 @@ +// Copyright 2021 Signal Messenger, LLC +// SPDX-License-Identifier: AGPL-3.0-only + .CompositionArea { position: relative; min-height: 42px; diff --git a/stylesheets/components/Input.scss b/stylesheets/components/Input.scss index 6d8d485d0..b02ed7f8b 100644 --- a/stylesheets/components/Input.scss +++ b/stylesheets/components/Input.scss @@ -1,3 +1,6 @@ +// Copyright 2021 Signal Messenger, LLC +// SPDX-License-Identifier: AGPL-3.0-only + .Input { &__container { @include font-body-1; diff --git a/stylesheets/components/LeftPaneDialog.scss b/stylesheets/components/LeftPaneDialog.scss index ec780a6b7..0bc0fd21c 100644 --- a/stylesheets/components/LeftPaneDialog.scss +++ b/stylesheets/components/LeftPaneDialog.scss @@ -1,3 +1,6 @@ +// Copyright 2021 Signal Messenger, LLC +// SPDX-License-Identifier: AGPL-3.0-only + @keyframes progress-animation { 0% { background-position: 100%; diff --git a/ts/test-node/license_comments_test.ts b/ts/test-node/license_comments_test.ts index ea132c54f..04246c4cc 100644 --- a/ts/test-node/license_comments_test.ts +++ b/ts/test-node/license_comments_test.ts @@ -1,4 +1,4 @@ -// Copyright 2020 Signal Messenger, LLC +// Copyright 2020-2021 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only // This file is meant to be run frequently, so it doesn't check the license year. See the @@ -8,6 +8,7 @@ import { assert } from 'chai'; import { forEachRelevantFile, + getExtension, readFirstLines, } from '../util/lint/license_comments'; @@ -17,7 +18,15 @@ describe('license comments', () => { this.timeout(10000); await forEachRelevantFile(async file => { - const [firstLine, secondLine] = await readFirstLines(file, 2); + let firstLine: string; + let secondLine: string; + + if (getExtension(file) === '.sh') { + const firstThreeLines = await readFirstLines(file, 3); + [, firstLine, secondLine] = firstThreeLines; + } else { + [firstLine, secondLine] = await readFirstLines(file, 2); + } const { groups = {} } = firstLine.match( diff --git a/ts/util/lint/license_comments.ts b/ts/util/lint/license_comments.ts index b7cddb999..8eb83e56e 100644 --- a/ts/util/lint/license_comments.ts +++ b/ts/util/lint/license_comments.ts @@ -14,7 +14,7 @@ import pMap from 'p-map'; const exec = promisify(childProcess.exec); -const rootPath = path.join(__dirname, '..', '..'); +const rootPath = path.join(__dirname, '..', '..', '..'); const EXTENSIONS_TO_CHECK = new Set([ '.eslintignore', @@ -34,15 +34,27 @@ const EXTENSIONS_TO_CHECK = new Set([ '.md', '.plist', ]); -const FILES_TO_IGNORE = new Set([ - 'ISSUE_TEMPLATE.md', - 'Mp3LameEncoder.min.js', - 'PULL_REQUEST_TEMPLATE.md', - 'WebAudioRecorderMp3.js', -]); +const FILES_TO_IGNORE = new Set( + [ + '.github/ISSUE_TEMPLATE/bug_report.md', + '.github/PULL_REQUEST_TEMPLATE.md', + 'components/indexeddb-backbonejs-adapter/backbone-indexeddb.js', + 'components/mp3lameencoder/lib/Mp3LameEncoder.js', + 'components/qrcode/qrcode.js', + 'components/recorderjs/recorder.js', + 'components/recorderjs/recorderWorker.js', + 'components/webaudiorecorder/lib/WebAudioRecorder.js', + 'components/webaudiorecorder/lib/WebAudioRecorderMp3.js', + 'js/Mp3LameEncoder.min.js', + 'js/WebAudioRecorderMp3.js', + ].map( + // This makes sure the files are correct on Windows. + path.normalize + ) +); // This is not technically the real extension. -function getExtension(file: string): string { +export function getExtension(file: string): string { if (file.startsWith('.')) { return getExtension(`x.${file}`); } @@ -63,7 +75,8 @@ export async function forEachRelevantFile( await pMap( gitFiles, async (file: string) => { - if (FILES_TO_IGNORE.has(path.basename(file))) { + const repoPath = path.relative(rootPath, file); + if (FILES_TO_IGNORE.has(repoPath)) { return; }