summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/util/etc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /src/tools/clippy/util/etc
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/clippy/util/etc')
-rwxr-xr-xsrc/tools/clippy/util/etc/pre-commit.sh22
-rw-r--r--src/tools/clippy/util/etc/vscode-tasks.json57
2 files changed, 79 insertions, 0 deletions
diff --git a/src/tools/clippy/util/etc/pre-commit.sh b/src/tools/clippy/util/etc/pre-commit.sh
new file mode 100755
index 000000000..5dd2ba3d5
--- /dev/null
+++ b/src/tools/clippy/util/etc/pre-commit.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+# hide output
+set -e
+
+# Update lints
+cargo dev update_lints
+git add clippy_lints/src/lib.rs
+git add clippy_lints/src/lib.*.rs
+
+# Formatting:
+# Git will not automatically add the formatted code to the staged changes once
+# fmt was executed. This collects all staged files rs files that are currently staged.
+# They will later be added back.
+#
+# This was proudly stolen and adjusted from here:
+# https://medium.com/@harshitbangar/automatic-code-formatting-with-git-66c3c5c26798
+files=$( (git diff --cached --name-only --diff-filter=ACMR | grep -Ei "\.rs$") || true)
+if [ ! -z "${files}" ]; then
+ cargo dev fmt
+ git add $(echo "$files" | paste -s -d " " -)
+fi
diff --git a/src/tools/clippy/util/etc/vscode-tasks.json b/src/tools/clippy/util/etc/vscode-tasks.json
new file mode 100644
index 000000000..ab98f9b41
--- /dev/null
+++ b/src/tools/clippy/util/etc/vscode-tasks.json
@@ -0,0 +1,57 @@
+{
+ "version": "2.0.0",
+ "tasks": [
+ {
+ "label": "cargo check",
+ "type": "shell",
+ "command": "cargo check",
+ "problemMatcher": [],
+ "group": {
+ "kind": "build",
+ "isDefault": true
+ }
+ },
+ {
+ "label": "cargo dev fmt",
+ "type": "shell",
+ "command": "cargo dev fmt",
+ "problemMatcher": [],
+ "group": "none"
+ },
+ {
+ "label": "cargo uitest",
+ "type": "shell",
+ "command": "cargo uitest",
+ "options": {
+ "env": {
+ // This task will usually execute all UI tests inside `tests/ui` you can
+ // optionally uncomment the line below and only run a specific test.
+ //
+ // See: https://github.com/rust-lang/rust-clippy/blob/master/book/src/development/adding_lints.md#testing
+ //
+ // "TESTNAME": "<TODO>",
+ "RUST_BACKTRACE": "1"
+ }
+ },
+ "problemMatcher": [],
+ "group": {
+ "kind": "test",
+ "isDefault": true
+ }
+ },
+ {
+ "label": "cargo test",
+ "type": "shell",
+ "command": "cargo test",
+ "problemMatcher": [],
+ "group": "test"
+ },
+ {
+ "label": "cargo dev bless",
+ "type": "shell",
+ "command": "cargo dev bless",
+ "problemMatcher": [],
+ "group": "none"
+ }
+ ]
+}