From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- src/tools/clippy/util/etc/pre-commit.sh | 22 +++++++++++ src/tools/clippy/util/etc/vscode-tasks.json | 57 +++++++++++++++++++++++++++++ src/tools/clippy/util/fetch_prs_between.sh | 27 ++++++++++++++ src/tools/clippy/util/versions.py | 44 ++++++++++++++++++++++ 4 files changed, 150 insertions(+) create mode 100755 src/tools/clippy/util/etc/pre-commit.sh create mode 100644 src/tools/clippy/util/etc/vscode-tasks.json create mode 100755 src/tools/clippy/util/fetch_prs_between.sh create mode 100755 src/tools/clippy/util/versions.py (limited to 'src/tools/clippy/util') 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": "", + "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" + } + ] +} diff --git a/src/tools/clippy/util/fetch_prs_between.sh b/src/tools/clippy/util/fetch_prs_between.sh new file mode 100755 index 000000000..6865abf97 --- /dev/null +++ b/src/tools/clippy/util/fetch_prs_between.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# Fetches the merge commits between two git commits and prints the PR URL +# together with the full commit message +# +# If you want to use this to update the Clippy changelog, be sure to manually +# exclude the non-user facing changes like 'rustup' PRs, typo fixes, etc. + +first=$1 +last=$2 + +IFS=' +' +for pr in $(git log --oneline --grep "Merge #" --grep "Merge pull request" --grep "Auto merge of" --grep "Rollup merge of" "$first...$last" | sort -rn | uniq); do + id=$(echo "$pr" | rg -o '#[0-9]{3,5}' | cut -c 2-) + commit=$(echo "$pr" | cut -d' ' -f 1) + message=$(git --no-pager show --pretty=medium "$commit") + if [[ -n $(echo "$message" | rg "^[\s]{4}changelog: [nN]one\.*$") ]]; then + continue + fi + + echo "URL: https://github.com/rust-lang/rust-clippy/pull/$id" + echo "Markdown URL: [#$id](https://github.com/rust-lang/rust-clippy/pull/$id)" + echo "$message" + echo "---------------------------------------------------------" + echo +done diff --git a/src/tools/clippy/util/versions.py b/src/tools/clippy/util/versions.py new file mode 100755 index 000000000..0cfa007d1 --- /dev/null +++ b/src/tools/clippy/util/versions.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python + +import json +import os +import sys +import logging as log +log.basicConfig(level=log.INFO, format='%(levelname)s: %(message)s') + + +def key(v): + if v == 'master': + return float('inf') + if v == 'stable': + return sys.maxsize + if v == 'beta': + return sys.maxsize - 1 + + v = v.replace('v', '').replace('rust-', '') + + s = 0 + for i, val in enumerate(v.split('.')[::-1]): + s += int(val) * 100**i + + return s + + +def main(): + if len(sys.argv) < 2: + log.error("specify output directory") + return + + outdir = sys.argv[1] + versions = [ + dir for dir in os.listdir(outdir) if not dir.startswith(".") and os.path.isdir(os.path.join(outdir, dir)) + ] + versions.sort(key=key) + + with open(os.path.join(outdir, "versions.json"), "w") as fp: + json.dump(versions, fp, indent=2) + log.info("wrote JSON for great justice") + + +if __name__ == "__main__": + main() -- cgit v1.2.3