Skip to content

Commit 51aefbd

Browse files
committed
Auto merge of #6735 - matthiaskrgr:lintcheck, r=flip1995
lintcheck: accept env var to set crates.toml file *Please write a short comment explaining your change (or "none" for internal only changes)* changelog: lintcheck: accept LINTCHECK_TOML env var to set list of crates to be checked.
2 parents 0ce5ecc + 0256103 commit 51aefbd

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

clippy_dev/README.md

+25-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,32 @@ cargo dev-lintcheck
2121

2222
By default the logs will be saved into `lintcheck-logs/lintcheck_crates_logs.txt`.
2323

24-
You can set a custom sources.toml by adding `--crates-toml custom.toml`
24+
You can set a custom sources.toml by adding `--crates-toml custom.toml` or using `LINTCHECK_TOML="custom.toml"`
2525
where `custom.toml` must be a relative path from the repo root.
2626

2727
The results will then be saved to `lintcheck-logs/custom_logs.toml`.
2828

29+
### Configuring the Crate Sources
30+
31+
The sources to check are saved in a `toml` file.
32+
There are three types of sources.
33+
A crates-io source:
34+
````toml
35+
bitflags = {name = "bitflags", versions = ['1.2.1']}
36+
````
37+
Requires a "name" and one or multiple "versions" to be checked.
38+
39+
A git source:
40+
````toml
41+
puffin = {name = "puffin", git_url = "https://github.com/EmbarkStudios/puffin", git_hash = "02dd4a3"}
42+
````
43+
Requires a name, the url to the repo and unique identifier of a commit,
44+
branch or tag which is checked out before linting.
45+
There is no way to always check `HEAD` because that would lead to changing lint-results as the repo would get updated.
46+
If `git_url` or `git_hash` is missing, an error will be thrown.
47+
48+
A local dependency:
49+
````toml
50+
clippy = {name = "clippy", path = "/home/user/clippy"}
51+
````
52+
For when you want to add a repository that is not published yet.

clippy_dev/src/lintcheck.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::clippy_project_root;
1111

1212
use std::collections::HashMap;
1313
use std::process::Command;
14-
use std::{fmt, fs::write, path::PathBuf};
14+
use std::{env, fmt, fs::write, path::PathBuf};
1515

1616
use clap::ArgMatches;
1717
use serde::{Deserialize, Serialize};
@@ -227,7 +227,9 @@ fn build_clippy() {
227227

228228
// get a list of CrateSources we want to check from a "lintcheck_crates.toml" file.
229229
fn read_crates(toml_path: Option<&str>) -> (String, Vec<CrateSource>) {
230-
let toml_path = PathBuf::from(toml_path.unwrap_or("clippy_dev/lintcheck_crates.toml"));
230+
let toml_path = PathBuf::from(
231+
env::var("LINTCHECK_TOML").unwrap_or(toml_path.unwrap_or("clippy_dev/lintcheck_crates.toml").to_string()),
232+
);
231233
// save it so that we can use the name of the sources.toml as name for the logfile later.
232234
let toml_filename = toml_path.file_stem().unwrap().to_str().unwrap().to_string();
233235
let toml_content: String =

0 commit comments

Comments
 (0)