Skip to content

Commit

Permalink
Add copyrights and pre-commit check. (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Loitsch authored Jun 11, 2021
1 parent 67a9dc9 commit d25e57d
Show file tree
Hide file tree
Showing 19 changed files with 124 additions and 4 deletions.
38 changes: 38 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

# Copyright (C) 2021 Toitware ApS. All rights reserved.
# Use of this source code is governed by an MIT-style license that can be
# found in the LICENSE file.

EXTENSIONS="*.ts *.toit *.js"

new_files=$(git diff --name-only --diff-filter=A --cached -- $EXTENSIONS)
new_files=$(find vscode/src -name "*.ts")

for f in $new_files; do
if ! grep -L "Copyright .* Toitware" "$f" 2>&1 1>/dev/null; then
missing_copyright="$f $missing_copyright"
else
if ! grep -L "governed.*MIT" "$f" 2>&1 1>/dev/null; then
missing_mit="$f $missing_mit"
fi
fi
done

if [ -n "$missing_copyright" ]; then
echo "Missing copyright in:"
for f in $missing_copyright; do
echo " $f"
done
fi

if [ -n "$missing_mit" ]; then
echo "Missing MIT line:"
for f in $missing_mit; do
echo " $f"
done
fi

if [ -n "$missing_copyright" ] || [ -n "$missing_mit" ]; then
exit 1;
fi
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,15 @@
# ide-tools
Tools for working with Toit in different IDEs

## Development
To have automatic checks for copyright and MIT notices, run

```
$ git config core.hooksPath .githooks
```

If a file doesn't need a copyright/MIT notice, use the following to skip
the check:
```
git commit --no-verify
```
5 changes: 3 additions & 2 deletions code_mirror/toit.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// CodeMirror, copyright (c) by Toitware ApS.
// Distributed under an MIT license: https://codemirror.net/LICENSE
// Copyright (C) 2021 Toitware ApS. All rights reserved.
// Use of this source code is governed by an MIT-style license that can be
// found in the LICENSE file.

(function (mod) {
if (typeof window === "undefined" || typeof window.navigator == 'undefined')
Expand Down
4 changes: 4 additions & 0 deletions vim/syntax/toit.vim
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
" Copyright (C) 2021 Toitware ApS. All rights reserved.
" Use of this source code is governed by an MIT-style license that can be
" found in the LICENSE file.

" The VIM syntax documentation:
" http://vimdoc.sourceforge.net/htmldoc/syntax.html#syntax
" The Pattern format:
Expand Down
8 changes: 7 additions & 1 deletion vscode/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// Copyright (C) 2021 Toitware ApS. All rights reserved.
// Use of this source code is governed by an MIT-style license that can be
// found in the LICENSE file.


import { ThemeIcon, TreeItem, TreeItemCollapsibleState } from "vscode";
import { Device, RelatedDevice } from "./device";

Expand Down Expand Up @@ -55,6 +60,7 @@ export class App extends TreeItem implements RelatedApp, RelatedDevice {
// TreeItem fields
this.contextValue = "application";
this.iconPath = new ThemeIcon("primitive-square");

}

app(): App {
Expand All @@ -65,4 +71,4 @@ export class App extends TreeItem implements RelatedApp, RelatedDevice {
return this.dev;
}

}
}
7 changes: 6 additions & 1 deletion vscode/src/device.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (C) 2021 Toitware ApS. All rights reserved.
// Use of this source code is governed by an MIT-style license that can be
// found in the LICENSE file.

import { MarkdownString, ThemeColor, ThemeIcon, TreeItem, TreeItemCollapsibleState } from "vscode";

/**
Expand All @@ -23,6 +27,7 @@ export class Device extends TreeItem implements RelatedDevice {
static activeIcons = new ThemeIcon("pulse", new ThemeColor("debugIcon.startForeground"));
static inactiveIcons = new ThemeIcon("remove", new ThemeColor("debugIcon.stopForeground"));


deviceID: string;
isSimulator: boolean;
name: string;
Expand Down Expand Up @@ -74,4 +79,4 @@ ${new Date(device.lastSeen).toLocaleDateString(undefined, {"weekday": "long", "y
device(): Device {
return this;
}
}
}
4 changes: 4 additions & 0 deletions vscode/src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (C) 2021 Toitware ApS. All rights reserved.
// Use of this source code is governed by an MIT-style license that can be
// found in the LICENSE file.

import { commands as Commands, ExtensionContext } from "vscode";
import { activateLsp, deactivateLsp } from "./lspClient";
import { activateToitStatusBar, createSetOrgCommand } from "./organization";
Expand Down
4 changes: 4 additions & 0 deletions vscode/src/lspClient.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (C) 2021 Toitware ApS. All rights reserved.
// Use of this source code is governed by an MIT-style license that can be
// found in the LICENSE file.

import * as fs from "fs";
import { platform } from "os";
import * as p from "path";
Expand Down
5 changes: 5 additions & 0 deletions vscode/src/org.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
/* eslint-disable @typescript-eslint/naming-convention */

// Copyright (C) 2021 Toitware ApS. All rights reserved.
// Use of this source code is governed by an MIT-style license that can be
// found in the LICENSE file.

export interface ConsoleOrganization {
name: string;
organization_id: string;
Expand Down
4 changes: 4 additions & 0 deletions vscode/src/organization.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (C) 2021 Toitware ApS. All rights reserved.
// Use of this source code is governed by an MIT-style license that can be
// found in the LICENSE file.

import { ExtensionContext, StatusBarAlignment, window as Window } from "vscode";
import { CommandContext, ensureAuth, getFirmwareVersion, getOrganization, selectOrganization, setOrganization } from "./utils";

Expand Down
4 changes: 4 additions & 0 deletions vscode/src/toitAuth.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (C) 2021 Toitware ApS. All rights reserved.
// Use of this source code is governed by an MIT-style license that can be
// found in the LICENSE file.

import { window as Window } from "vscode";
import { CommandContext, ensureAuth } from "./utils";

Expand Down
4 changes: 4 additions & 0 deletions vscode/src/toitExec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (C) 2021 Toitware ApS. All rights reserved.
// Use of this source code is governed by an MIT-style license that can be
// found in the LICENSE file.

import { promisify } from "util";
import { OutputChannel, window as Window } from "vscode";
import { Device } from "./device";
Expand Down
4 changes: 4 additions & 0 deletions vscode/src/toitMonitor.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (C) 2021 Toitware ApS. All rights reserved.
// Use of this source code is governed by an MIT-style license that can be
// found in the LICENSE file.

import { window as Window } from "vscode";
import { CommandContext, ensureAuth, selectPort } from "./utils";

Expand Down
4 changes: 4 additions & 0 deletions vscode/src/toitProvision.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (C) 2021 Toitware ApS. All rights reserved.
// Use of this source code is governed by an MIT-style license that can be
// found in the LICENSE file.

import { window as Window } from "vscode";
import { CommandContext, ensureAuth, promptForWiFiInfo, selectPort, WiFiInfo } from "./utils";

Expand Down
4 changes: 4 additions & 0 deletions vscode/src/toitSimulator.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (C) 2021 Toitware ApS. All rights reserved.
// Use of this source code is governed by an MIT-style license that can be
// found in the LICENSE file.

import cp = require("child_process");
import { OutputChannel, window as Window } from "vscode";
import { Device, RelatedDevice } from "./device";
Expand Down
4 changes: 4 additions & 0 deletions vscode/src/toitUninstall.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (C) 2021 Toitware ApS. All rights reserved.
// Use of this source code is governed by an MIT-style license that can be
// found in the LICENSE file.

import { App, RelatedApp } from "./app";
import { CommandContext, uninstallApp } from "./utils";

Expand Down
4 changes: 4 additions & 0 deletions vscode/src/treeView.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (C) 2021 Toitware ApS. All rights reserved.
// Use of this source code is governed by an MIT-style license that can be
// found in the LICENSE file.

import { Event, EventEmitter, TreeDataProvider, TreeItem, window as Window } from "vscode";
import { App } from "./app";
import { Device } from "./device";
Expand Down
4 changes: 4 additions & 0 deletions vscode/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (C) 2021 Toitware ApS. All rights reserved.
// Use of this source code is governed by an MIT-style license that can be
// found in the LICENSE file.

import { promisify } from "util";
import { InputBoxOptions, OutputChannel, QuickPickItem, StatusBarItem, Terminal, TreeItem, window as Window, workspace as Workspace } from "vscode";
import { App, ConsoleApp } from "./app";
Expand Down
4 changes: 4 additions & 0 deletions vscode/syntaxes/toit.tmLanguage.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Copyright (C) 2021 Toitware ApS. All rights reserved.
# Use of this source code is governed by an MIT-style license that can be
# found in the LICENSE file.

---
comment: >
Don't edit the JSON file, but edit the YAML file instead.
Expand Down

0 comments on commit d25e57d

Please sign in to comment.