lintrunner 0.12.0__tar.gz → 0.12.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of lintrunner might be problematic. Click here for more details.

Files changed (68) hide show
  1. {lintrunner-0.12.0 → lintrunner-0.12.2}/CHANGELOG.md +7 -0
  2. {lintrunner-0.12.0 → lintrunner-0.12.2}/Cargo.lock +3 -3
  3. {lintrunner-0.12.0 → lintrunner-0.12.2}/Cargo.toml +1 -1
  4. {lintrunner-0.12.0 → lintrunner-0.12.2}/PKG-INFO +1 -1
  5. {lintrunner-0.12.0 → lintrunner-0.12.2}/src/git.rs +2 -2
  6. {lintrunner-0.12.0 → lintrunner-0.12.2}/src/lib.rs +11 -1
  7. {lintrunner-0.12.0 → lintrunner-0.12.2}/src/main.rs +0 -4
  8. {lintrunner-0.12.0 → lintrunner-0.12.2}/src/persistent_data.rs +11 -6
  9. {lintrunner-0.12.0 → lintrunner-0.12.2}/src/sapling.rs +8 -8
  10. {lintrunner-0.12.0 → lintrunner-0.12.2}/src/testing.rs +3 -3
  11. lintrunner-0.12.2/src/version_control.rs +26 -0
  12. lintrunner-0.12.0/src/version_control.rs +0 -71
  13. {lintrunner-0.12.0 → lintrunner-0.12.2}/.github/workflows/CI.yml +0 -0
  14. {lintrunner-0.12.0 → lintrunner-0.12.2}/.github/workflows/Lint.yml +0 -0
  15. {lintrunner-0.12.0 → lintrunner-0.12.2}/.gitignore +0 -0
  16. {lintrunner-0.12.0 → lintrunner-0.12.2}/.lintrunner.toml +0 -0
  17. {lintrunner-0.12.0 → lintrunner-0.12.2}/LICENSE +0 -0
  18. {lintrunner-0.12.0 → lintrunner-0.12.2}/README.md +0 -0
  19. {lintrunner-0.12.0 → lintrunner-0.12.2}/cliff.toml +0 -0
  20. {lintrunner-0.12.0 → lintrunner-0.12.2}/do_release.sh +0 -0
  21. {lintrunner-0.12.0 → lintrunner-0.12.2}/examples/config_example.toml +0 -0
  22. {lintrunner-0.12.0 → lintrunner-0.12.2}/examples/flake8_linter.py +0 -0
  23. {lintrunner-0.12.0 → lintrunner-0.12.2}/examples/rustfmt_linter.py +0 -0
  24. {lintrunner-0.12.0 → lintrunner-0.12.2}/pyproject.toml +0 -0
  25. {lintrunner-0.12.0 → lintrunner-0.12.2}/rustfmt.toml +0 -0
  26. {lintrunner-0.12.0 → lintrunner-0.12.2}/src/init.rs +0 -0
  27. {lintrunner-0.12.0 → lintrunner-0.12.2}/src/lint_config.rs +0 -0
  28. {lintrunner-0.12.0 → lintrunner-0.12.2}/src/lint_message.rs +0 -0
  29. {lintrunner-0.12.0 → lintrunner-0.12.2}/src/linter.rs +0 -0
  30. {lintrunner-0.12.0 → lintrunner-0.12.2}/src/log_utils.rs +0 -0
  31. {lintrunner-0.12.0 → lintrunner-0.12.2}/src/path.rs +0 -0
  32. {lintrunner-0.12.0 → lintrunner-0.12.2}/src/rage.rs +0 -0
  33. {lintrunner-0.12.0 → lintrunner-0.12.2}/src/render.rs +0 -0
  34. {lintrunner-0.12.0 → lintrunner-0.12.2}/tests/fixtures/fake_source_file.rs +0 -0
  35. {lintrunner-0.12.0 → lintrunner-0.12.2}/tests/integration_test.rs +0 -0
  36. {lintrunner-0.12.0 → lintrunner-0.12.2}/tests/snapshots/integration_test__changed_init_causes_warning_1.snap +0 -0
  37. {lintrunner-0.12.0 → lintrunner-0.12.2}/tests/snapshots/integration_test__changed_init_causes_warning_2.snap +0 -0
  38. {lintrunner-0.12.0 → lintrunner-0.12.2}/tests/snapshots/integration_test__duplicate_code_fails.snap +0 -0
  39. {lintrunner-0.12.0 → lintrunner-0.12.2}/tests/snapshots/integration_test__empty_command_fails.snap +0 -0
  40. {lintrunner-0.12.0 → lintrunner-0.12.2}/tests/snapshots/integration_test__excluding_dryrun_fails.snap +0 -0
  41. {lintrunner-0.12.0 → lintrunner-0.12.2}/tests/snapshots/integration_test__format_command_doesnt_use_nonformat_linter.snap +0 -0
  42. {lintrunner-0.12.0 → lintrunner-0.12.2}/tests/snapshots/integration_test__git_head_files.snap +0 -0
  43. {lintrunner-0.12.0 → lintrunner-0.12.2}/tests/snapshots/integration_test__git_no_changes.snap +0 -0
  44. {lintrunner-0.12.0 → lintrunner-0.12.2}/tests/snapshots/integration_test__init_suppresses_warning.snap +0 -0
  45. {lintrunner-0.12.0 → lintrunner-0.12.2}/tests/snapshots/integration_test__invalid_args.snap +0 -0
  46. {lintrunner-0.12.0 → lintrunner-0.12.2}/tests/snapshots/integration_test__invalid_config_fails.snap +0 -0
  47. {lintrunner-0.12.0 → lintrunner-0.12.2}/tests/snapshots/integration_test__invalid_paths_cmd_and_from.snap +0 -0
  48. {lintrunner-0.12.0 → lintrunner-0.12.2}/tests/snapshots/integration_test__invalid_paths_cmd_and_specified_paths.snap +0 -0
  49. {lintrunner-0.12.0 → lintrunner-0.12.2}/tests/snapshots/integration_test__lint_with_no_linters.snap +0 -0
  50. {lintrunner-0.12.0 → lintrunner-0.12.2}/tests/snapshots/integration_test__linter_hard_failure_is_caught.snap +0 -0
  51. {lintrunner-0.12.0 → lintrunner-0.12.2}/tests/snapshots/integration_test__linter_nonexistent_command.snap +0 -0
  52. {lintrunner-0.12.0 → lintrunner-0.12.2}/tests/snapshots/integration_test__linter_providing_nonexistent_path_degrades_gracefully.snap +0 -0
  53. {lintrunner-0.12.0 → lintrunner-0.12.2}/tests/snapshots/integration_test__linter_replacement_trailing_newlines.snap +0 -0
  54. {lintrunner-0.12.0 → lintrunner-0.12.2}/tests/snapshots/integration_test__no_op_config_succeeds.snap +0 -0
  55. {lintrunner-0.12.0 → lintrunner-0.12.2}/tests/snapshots/integration_test__rage_command_output.snap +0 -0
  56. {lintrunner-0.12.0 → lintrunner-0.12.2}/tests/snapshots/integration_test__simple_linter.snap +0 -0
  57. {lintrunner-0.12.0 → lintrunner-0.12.2}/tests/snapshots/integration_test__simple_linter_fails_on_nonexistent_file.snap +0 -0
  58. {lintrunner-0.12.0 → lintrunner-0.12.2}/tests/snapshots/integration_test__simple_linter_fake_second_config.snap +0 -0
  59. {lintrunner-0.12.0 → lintrunner-0.12.2}/tests/snapshots/integration_test__simple_linter_oneline.snap +0 -0
  60. {lintrunner-0.12.0 → lintrunner-0.12.2}/tests/snapshots/integration_test__simple_linter_only_under_dir.snap +0 -0
  61. {lintrunner-0.12.0 → lintrunner-0.12.2}/tests/snapshots/integration_test__simple_linter_replacement_message.snap +0 -0
  62. {lintrunner-0.12.0 → lintrunner-0.12.2}/tests/snapshots/integration_test__simple_linter_two_configs.snap +0 -0
  63. {lintrunner-0.12.0 → lintrunner-0.12.2}/tests/snapshots/integration_test__skip_nonexistent_linter.snap +0 -0
  64. {lintrunner-0.12.0 → lintrunner-0.12.2}/tests/snapshots/integration_test__take_nonexistent_linter.snap +0 -0
  65. {lintrunner-0.12.0 → lintrunner-0.12.2}/tests/snapshots/integration_test__tee_json.snap +0 -0
  66. {lintrunner-0.12.0 → lintrunner-0.12.2}/tests/snapshots/integration_test__unknown_config_fails.snap +0 -0
  67. {lintrunner-0.12.0 → lintrunner-0.12.2}/tools/convert_to_sarif.py +0 -0
  68. {lintrunner-0.12.0 → lintrunner-0.12.2}/tools/convert_to_sarif_test.py +0 -0
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [0.12.1] - 2024-02-10
6
+
7
+ ### Bug Fixes
8
+
9
+ - Properly filter ignored files in sapling all-files ([34dd8b2](https://github.com/suo/lintrunner/commit/34dd8b295c58b1055916f18dd55272fffc64e705))
10
+ - Make rage command robust to missing data ([a96ceec](https://github.com/suo/lintrunner/commit/a96ceec6ce3f8ae798f08d34c5f6de133814363b))
11
+
5
12
  ## [0.12.0] - 2024-02-10
6
13
 
7
14
  ### Bug Fixes
@@ -327,9 +327,9 @@ checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10"
327
327
 
328
328
  [[package]]
329
329
  name = "either"
330
- version = "1.9.0"
330
+ version = "1.10.0"
331
331
  source = "registry+https://github.com/rust-lang/crates.io-index"
332
- checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
332
+ checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a"
333
333
 
334
334
  [[package]]
335
335
  name = "encode_unicode"
@@ -586,7 +586,7 @@ checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"
586
586
 
587
587
  [[package]]
588
588
  name = "lintrunner"
589
- version = "0.12.0"
589
+ version = "0.12.2"
590
590
  dependencies = [
591
591
  "anyhow",
592
592
  "assert_cmd",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "lintrunner"
3
- version = "0.12.0"
3
+ version = "0.12.2"
4
4
  authors = ["Michael Suo <suo@fb.com>"]
5
5
  edition = "2021"
6
6
  description = "A lint running tool and framework."
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lintrunner
3
- Version: 0.12.0
3
+ Version: 0.12.2
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
6
  Classifier: Programming Language :: Python :: Implementation :: PyPy
@@ -3,7 +3,7 @@ use std::{collections::HashSet, convert::TryFrom, process::Command};
3
3
  use crate::{
4
4
  log_utils::{ensure_output, log_files},
5
5
  path::AbsPath,
6
- version_control,
6
+ version_control::VersionControl,
7
7
  };
8
8
  use anyhow::{ensure, Context, Result};
9
9
  use log::debug;
@@ -13,7 +13,7 @@ pub struct Repo {
13
13
  root: AbsPath,
14
14
  }
15
15
 
16
- impl version_control::System for Repo {
16
+ impl VersionControl for Repo {
17
17
  fn new() -> Result<Repo> {
18
18
  // Retrieve the git root based on the current working directory.
19
19
  let output = Command::new("git")
@@ -13,6 +13,7 @@ use std::convert::TryFrom;
13
13
  use std::fs::OpenOptions;
14
14
  use std::sync::{Arc, Mutex};
15
15
  use std::thread;
16
+ use version_control::VersionControl;
16
17
 
17
18
  pub mod git;
18
19
  pub mod init;
@@ -150,8 +151,16 @@ pub enum RenderOpt {
150
151
  Oneline,
151
152
  }
152
153
 
154
+ pub fn get_version_control() -> Result<Box<dyn VersionControl>> {
155
+ let repo = git::Repo::new();
156
+ if let Ok(repo) = repo {
157
+ return Ok(Box::new(repo));
158
+ }
159
+
160
+ Ok(Box::new(sapling::Repo::new()?))
161
+ }
162
+
153
163
  pub fn do_lint(
154
- repo: &version_control::Repo,
155
164
  linters: Vec<Linter>,
156
165
  paths_opt: PathsOpt,
157
166
  should_apply_patches: bool,
@@ -165,6 +174,7 @@ pub fn do_lint(
165
174
  "Running linters: {:?}",
166
175
  linters.iter().map(|l| &l.code).collect::<Vec<_>>()
167
176
  );
177
+ let repo = get_version_control()?;
168
178
  let mut stdout = Term::stdout();
169
179
  if linters.is_empty() {
170
180
  stdout.write_line("No linters ran.")?;
@@ -190,8 +190,6 @@ fn do_main() -> Result<i32> {
190
190
  debug!("Version: {VERSION}");
191
191
  debug!("Passed args: {:?}", std::env::args());
192
192
  debug!("Computed args: {:?}", args);
193
- let repo = version_control::Repo::new()?;
194
- debug!("Current rev: {}", repo.get_head()?);
195
193
 
196
194
  // report config paths which do not exist
197
195
  for path in &config_paths {
@@ -293,7 +291,6 @@ fn do_main() -> Result<i32> {
293
291
  SubCommand::Format => {
294
292
  check_init_changed(&persistent_data_store, &lint_runner_config)?;
295
293
  do_lint(
296
- &repo,
297
294
  linters,
298
295
  paths_opt,
299
296
  true, // always apply patches when we use the format command
@@ -308,7 +305,6 @@ fn do_main() -> Result<i32> {
308
305
  // Default command is to just lint.
309
306
  check_init_changed(&persistent_data_store, &lint_runner_config)?;
310
307
  do_lint(
311
- &repo,
312
308
  linters,
313
309
  paths_opt,
314
310
  args.apply_patches,
@@ -175,7 +175,7 @@ impl PersistentDataStore {
175
175
  .collect::<Result<Vec<_>, std::io::Error>>()?;
176
176
 
177
177
  run_dirs.sort_unstable();
178
- run_dirs.pop(); // Don't include the current run.
178
+ run_dirs.pop(); // pop most recent job as it won't have a report yet.
179
179
  run_dirs.reverse();
180
180
 
181
181
  debug!("Found past runs: {:?}", run_dirs);
@@ -209,14 +209,19 @@ impl PersistentDataStore {
209
209
 
210
210
  let mut ret = Vec::new();
211
211
 
212
- // Skip the first one as it is the current run.
213
212
  for dir in run_dirs.into_iter() {
214
213
  debug!("Reading run info from {}", dir.display());
214
+ let run_data = std::fs::read_to_string(dir.join("run_info.json"));
215
+ let exit_data = std::fs::read_to_string(dir.join("exit_info.json"));
216
+ if run_data.is_err() || exit_data.is_err() {
217
+ // If we couldn't find one of the runfiles, just skip it. We can
218
+ // fail to write it for a variety of reasons, including a simple
219
+ // sigterm.
220
+ continue;
221
+ }
215
222
 
216
- let run_info: RunInfo =
217
- serde_json::from_str(&std::fs::read_to_string(dir.join("run_info.json"))?)?;
218
- let exit_info: ExitInfo =
219
- serde_json::from_str(&std::fs::read_to_string(dir.join("exit_info.json"))?)?;
223
+ let run_info: RunInfo = serde_json::from_str(&run_data?)?;
224
+ let exit_info: ExitInfo = serde_json::from_str(&exit_data?)?;
220
225
  ret.push((run_info, exit_info));
221
226
  }
222
227
  Ok(ret)
@@ -1,7 +1,7 @@
1
1
  use crate::{
2
2
  log_utils,
3
3
  path::{self, AbsPath},
4
- version_control,
4
+ version_control::VersionControl,
5
5
  };
6
6
 
7
7
  use anyhow;
@@ -10,7 +10,7 @@ pub struct Repo {
10
10
  root: path::AbsPath,
11
11
  }
12
12
 
13
- impl version_control::System for Repo {
13
+ impl VersionControl for Repo {
14
14
  fn new() -> anyhow::Result<Self> {
15
15
  let output = std::process::Command::new("sl").arg("root").output()?;
16
16
  anyhow::ensure!(output.status.success(), "Failed to determine Sapling root");
@@ -59,16 +59,16 @@ impl version_control::System for Repo {
59
59
  cmd.current_dir(&self.root);
60
60
  let output = cmd.output()?;
61
61
  log_utils::ensure_output(&format!("{:?}", cmd), &output)?;
62
- let commit_files_str = std::str::from_utf8(&output.stdout)?;
63
- let commit_files: std::collections::HashSet<String> = commit_files_str
62
+ let all_files_str = std::str::from_utf8(&output.stdout)?;
63
+ let all_files: std::collections::HashSet<String> = all_files_str
64
64
  .split('\n')
65
65
  .map(|x| x.to_string())
66
+ .filter(|line| !line.starts_with('I'))
66
67
  .map(|line| re.replace(&line, "").to_string())
67
68
  .filter(|line| !line.is_empty())
68
- .filter(|line| !line.starts_with('I'))
69
69
  .collect();
70
70
 
71
- let filtered_commit_files = commit_files
71
+ let filtered_all_files = all_files
72
72
  .into_iter()
73
73
  .map(|f| format!("{}", self.root.join(f).display()))
74
74
  .filter_map(|f| match path::AbsPath::try_from(&f) {
@@ -80,7 +80,7 @@ impl version_control::System for Repo {
80
80
  })
81
81
  .collect::<Vec<path::AbsPath>>();
82
82
 
83
- Ok(filtered_commit_files)
83
+ Ok(filtered_all_files)
84
84
  }
85
85
 
86
86
  fn get_changed_files(&self, relative_to: Option<&str>) -> anyhow::Result<Vec<path::AbsPath>> {
@@ -134,7 +134,7 @@ mod tests {
134
134
  use std::{fs::OpenOptions, io::Write, sync::Mutex}; // 1.4.0
135
135
 
136
136
  static SL_GLOBAL_MUTEX: Lazy<Mutex<()>> = Lazy::new(Mutex::default);
137
- use crate::{testing, version_control::System};
137
+ use crate::testing;
138
138
 
139
139
  use super::*;
140
140
  use anyhow::Result;
@@ -1,6 +1,6 @@
1
1
  use std::{fs::OpenOptions, io::Write, process::Command};
2
2
 
3
- use crate::version_control;
3
+ use crate::get_version_control;
4
4
 
5
5
  use anyhow::Result;
6
6
  use tempfile::TempDir;
@@ -82,7 +82,7 @@ impl GitCheckout {
82
82
 
83
83
  pub fn changed_files(&self, relative_to: Option<&str>) -> Result<Vec<String>> {
84
84
  std::env::set_current_dir(self.root())?;
85
- let repo = version_control::Repo::new()?;
85
+ let repo = get_version_control()?;
86
86
  let files = repo.get_changed_files(relative_to)?;
87
87
  let files = files
88
88
  .into_iter()
@@ -93,7 +93,7 @@ impl GitCheckout {
93
93
 
94
94
  pub fn merge_base_with(&self, merge_base_with: &str) -> Result<String> {
95
95
  std::env::set_current_dir(self.root())?;
96
- let repo = version_control::Repo::new()?;
96
+ let repo = get_version_control()?;
97
97
  repo.get_merge_base_with(merge_base_with)
98
98
  }
99
99
 
@@ -0,0 +1,26 @@
1
+ use anyhow;
2
+
3
+ use crate::path::AbsPath;
4
+
5
+ // Trait describing the operations we need in lintrunner for a version
6
+ // control system.
7
+ pub trait VersionControl {
8
+ // Creates a new instance, trying the different implementations we
9
+ // have available.
10
+ fn new() -> anyhow::Result<Self>
11
+ where
12
+ Self: Sized;
13
+
14
+ // Gets the tip of the repository.
15
+ fn get_head(&self) -> anyhow::Result<String>;
16
+
17
+ // Gets the most recent common ancestor between the tip and the
18
+ // given commit.
19
+ fn get_merge_base_with(&self, merge_base_with: &str) -> anyhow::Result<String>;
20
+
21
+ // Gets the files that have changed relative to the given commit.
22
+ fn get_changed_files(&self, relative_to: Option<&str>) -> anyhow::Result<Vec<AbsPath>>;
23
+
24
+ // Get all files in the repo.
25
+ fn get_all_files(&self, under: Option<&AbsPath>) -> anyhow::Result<Vec<AbsPath>>;
26
+ }
@@ -1,71 +0,0 @@
1
- use crate::{
2
- git,
3
- path::{self, AbsPath},
4
- sapling,
5
- };
6
-
7
- use anyhow;
8
-
9
- pub struct Repo(RepoImpl);
10
-
11
- enum RepoImpl {
12
- Git(git::Repo),
13
- Sapling(sapling::Repo),
14
- }
15
-
16
- // Trait describing the operations we need in lintrunner for a version
17
- // control system.
18
- pub trait System {
19
- // Creates a new instance, trying the different implementations we
20
- // have available.
21
- fn new() -> anyhow::Result<Self>
22
- where
23
- Self: Sized;
24
-
25
- // Gets the tip of the repository.
26
- fn get_head(&self) -> anyhow::Result<String>;
27
-
28
- // Gets the most recent common ancestor between the tip and the
29
- // given commit.
30
- fn get_merge_base_with(&self, merge_base_with: &str) -> anyhow::Result<String>;
31
-
32
- // Gets the files that have changed relative to the given commit.
33
- fn get_changed_files(&self, relative_to: Option<&str>) -> anyhow::Result<Vec<path::AbsPath>>;
34
-
35
- // Get all files in the repo.
36
- fn get_all_files(&self, under: Option<&AbsPath>) -> anyhow::Result<Vec<AbsPath>>;
37
- }
38
-
39
- impl Repo {
40
- pub fn new() -> anyhow::Result<Self> {
41
- git::Repo::new()
42
- .and_then(|repo| Ok(Repo(RepoImpl::Git(repo))))
43
- .or_else(|_| sapling::Repo::new().and_then(|repo| Ok(Repo(RepoImpl::Sapling(repo)))))
44
- }
45
-
46
- pub fn get_head(&self) -> anyhow::Result<String> {
47
- self.get_system().get_head()
48
- }
49
-
50
- pub fn get_merge_base_with(&self, merge_base_with: &str) -> anyhow::Result<String> {
51
- self.get_system().get_merge_base_with(merge_base_with)
52
- }
53
-
54
- pub fn get_changed_files(
55
- &self,
56
- relative_to: Option<&str>,
57
- ) -> anyhow::Result<Vec<path::AbsPath>> {
58
- self.get_system().get_changed_files(relative_to)
59
- }
60
-
61
- fn get_system<'a>(&'a self) -> Box<&'a dyn System> {
62
- match &self.0 {
63
- RepoImpl::Git(git) => Box::new(git as &dyn System),
64
- RepoImpl::Sapling(sapling) => Box::new(sapling as &dyn System),
65
- }
66
- }
67
-
68
- pub fn get_all_files(&self, under: Option<&AbsPath>) -> anyhow::Result<Vec<AbsPath>> {
69
- self.get_system().get_all_files(under)
70
- }
71
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes