Skip to content

Commit

Permalink
Fix license header file enumeration
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanHahn-Signal committed Oct 1, 2021
1 parent c99066d commit b239502
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .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
Expand Down
3 changes: 3 additions & 0 deletions .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
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/backport.yml
@@ -1,4 +1,3 @@

# Copyright 2021 Signal Messenger, LLC
# SPDX-License-Identifier: AGPL-3.0-only

Expand Down
1 change: 0 additions & 1 deletion aptly.sh
@@ -1,5 +1,4 @@
#!/bin/bash

# Copyright 2017-2021 Signal Messenger, LLC
# SPDX-License-Identifier: AGPL-3.0-only

Expand Down
3 changes: 3 additions & 0 deletions 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
Expand Down
3 changes: 3 additions & 0 deletions 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;
Expand Down
3 changes: 3 additions & 0 deletions 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;
Expand Down
3 changes: 3 additions & 0 deletions 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%;
Expand Down
13 changes: 11 additions & 2 deletions 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
Expand All @@ -8,6 +8,7 @@ import { assert } from 'chai';

import {
forEachRelevantFile,
getExtension,
readFirstLines,
} from '../util/lint/license_comments';

Expand All @@ -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(
Expand Down
31 changes: 22 additions & 9 deletions ts/util/lint/license_comments.ts
Expand Up @@ -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',
Expand All @@ -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}`);
}
Expand All @@ -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;
}

Expand Down

0 comments on commit b239502

Please sign in to comment.