lintrunner 0.11.1__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.11.1 → lintrunner-0.12.2}/CHANGELOG.md +23 -0
  2. {lintrunner-0.11.1 → lintrunner-0.12.2}/Cargo.lock +53 -54
  3. {lintrunner-0.11.1 → lintrunner-0.12.2}/Cargo.toml +1 -1
  4. {lintrunner-0.11.1 → lintrunner-0.12.2}/PKG-INFO +1 -1
  5. {lintrunner-0.11.1 → lintrunner-0.12.2}/src/git.rs +37 -2
  6. {lintrunner-0.11.1 → lintrunner-0.12.2}/src/lib.rs +27 -10
  7. {lintrunner-0.11.1 → lintrunner-0.12.2}/src/main.rs +16 -6
  8. {lintrunner-0.11.1 → lintrunner-0.12.2}/src/persistent_data.rs +11 -6
  9. {lintrunner-0.11.1 → lintrunner-0.12.2}/src/sapling.rs +79 -4
  10. {lintrunner-0.11.1 → lintrunner-0.12.2}/src/testing.rs +3 -3
  11. lintrunner-0.12.2/src/version_control.rs +26 -0
  12. {lintrunner-0.11.1 → lintrunner-0.12.2}/tests/integration_test.rs +39 -0
  13. {lintrunner-0.11.1 → lintrunner-0.12.2}/tests/snapshots/integration_test__format_command_doesnt_use_nonformat_linter.snap +1 -3
  14. lintrunner-0.12.2/tests/snapshots/integration_test__lint_with_no_linters.snap +11 -0
  15. lintrunner-0.11.1/src/version_control.rs +0 -60
  16. {lintrunner-0.11.1 → lintrunner-0.12.2}/.github/workflows/CI.yml +0 -0
  17. {lintrunner-0.11.1 → lintrunner-0.12.2}/.github/workflows/Lint.yml +0 -0
  18. {lintrunner-0.11.1 → lintrunner-0.12.2}/.gitignore +0 -0
  19. {lintrunner-0.11.1 → lintrunner-0.12.2}/.lintrunner.toml +0 -0
  20. {lintrunner-0.11.1 → lintrunner-0.12.2}/LICENSE +0 -0
  21. {lintrunner-0.11.1 → lintrunner-0.12.2}/README.md +0 -0
  22. {lintrunner-0.11.1 → lintrunner-0.12.2}/cliff.toml +0 -0
  23. {lintrunner-0.11.1 → lintrunner-0.12.2}/do_release.sh +0 -0
  24. {lintrunner-0.11.1 → lintrunner-0.12.2}/examples/config_example.toml +0 -0
  25. {lintrunner-0.11.1 → lintrunner-0.12.2}/examples/flake8_linter.py +0 -0
  26. {lintrunner-0.11.1 → lintrunner-0.12.2}/examples/rustfmt_linter.py +0 -0
  27. {lintrunner-0.11.1 → lintrunner-0.12.2}/pyproject.toml +0 -0
  28. {lintrunner-0.11.1 → lintrunner-0.12.2}/rustfmt.toml +0 -0
  29. {lintrunner-0.11.1 → lintrunner-0.12.2}/src/init.rs +0 -0
  30. {lintrunner-0.11.1 → lintrunner-0.12.2}/src/lint_config.rs +0 -0
  31. {lintrunner-0.11.1 → lintrunner-0.12.2}/src/lint_message.rs +0 -0
  32. {lintrunner-0.11.1 → lintrunner-0.12.2}/src/linter.rs +0 -0
  33. {lintrunner-0.11.1 → lintrunner-0.12.2}/src/log_utils.rs +0 -0
  34. {lintrunner-0.11.1 → lintrunner-0.12.2}/src/path.rs +0 -0
  35. {lintrunner-0.11.1 → lintrunner-0.12.2}/src/rage.rs +0 -0
  36. {lintrunner-0.11.1 → lintrunner-0.12.2}/src/render.rs +0 -0
  37. {lintrunner-0.11.1 → lintrunner-0.12.2}/tests/fixtures/fake_source_file.rs +0 -0
  38. {lintrunner-0.11.1 → lintrunner-0.12.2}/tests/snapshots/integration_test__changed_init_causes_warning_1.snap +0 -0
  39. {lintrunner-0.11.1 → lintrunner-0.12.2}/tests/snapshots/integration_test__changed_init_causes_warning_2.snap +0 -0
  40. {lintrunner-0.11.1 → lintrunner-0.12.2}/tests/snapshots/integration_test__duplicate_code_fails.snap +0 -0
  41. {lintrunner-0.11.1 → lintrunner-0.12.2}/tests/snapshots/integration_test__empty_command_fails.snap +0 -0
  42. {lintrunner-0.11.1 → lintrunner-0.12.2}/tests/snapshots/integration_test__excluding_dryrun_fails.snap +0 -0
  43. {lintrunner-0.11.1 → lintrunner-0.12.2}/tests/snapshots/integration_test__git_head_files.snap +0 -0
  44. {lintrunner-0.11.1 → lintrunner-0.12.2}/tests/snapshots/integration_test__git_no_changes.snap +0 -0
  45. {lintrunner-0.11.1 → lintrunner-0.12.2}/tests/snapshots/integration_test__init_suppresses_warning.snap +0 -0
  46. {lintrunner-0.11.1 → lintrunner-0.12.2}/tests/snapshots/integration_test__invalid_args.snap +0 -0
  47. {lintrunner-0.11.1 → lintrunner-0.12.2}/tests/snapshots/integration_test__invalid_config_fails.snap +0 -0
  48. {lintrunner-0.11.1 → lintrunner-0.12.2}/tests/snapshots/integration_test__invalid_paths_cmd_and_from.snap +0 -0
  49. {lintrunner-0.11.1 → lintrunner-0.12.2}/tests/snapshots/integration_test__invalid_paths_cmd_and_specified_paths.snap +0 -0
  50. {lintrunner-0.11.1 → lintrunner-0.12.2}/tests/snapshots/integration_test__linter_hard_failure_is_caught.snap +0 -0
  51. {lintrunner-0.11.1 → lintrunner-0.12.2}/tests/snapshots/integration_test__linter_nonexistent_command.snap +0 -0
  52. {lintrunner-0.11.1 → lintrunner-0.12.2}/tests/snapshots/integration_test__linter_providing_nonexistent_path_degrades_gracefully.snap +0 -0
  53. {lintrunner-0.11.1 → lintrunner-0.12.2}/tests/snapshots/integration_test__linter_replacement_trailing_newlines.snap +0 -0
  54. {lintrunner-0.11.1 → lintrunner-0.12.2}/tests/snapshots/integration_test__no_op_config_succeeds.snap +0 -0
  55. {lintrunner-0.11.1 → lintrunner-0.12.2}/tests/snapshots/integration_test__rage_command_output.snap +0 -0
  56. {lintrunner-0.11.1 → lintrunner-0.12.2}/tests/snapshots/integration_test__simple_linter.snap +0 -0
  57. {lintrunner-0.11.1 → lintrunner-0.12.2}/tests/snapshots/integration_test__simple_linter_fails_on_nonexistent_file.snap +0 -0
  58. {lintrunner-0.11.1 → lintrunner-0.12.2}/tests/snapshots/integration_test__simple_linter_fake_second_config.snap +0 -0
  59. {lintrunner-0.11.1 → lintrunner-0.12.2}/tests/snapshots/integration_test__simple_linter_oneline.snap +0 -0
  60. {lintrunner-0.11.1 → lintrunner-0.12.2}/tests/snapshots/integration_test__simple_linter_only_under_dir.snap +0 -0
  61. {lintrunner-0.11.1 → lintrunner-0.12.2}/tests/snapshots/integration_test__simple_linter_replacement_message.snap +0 -0
  62. {lintrunner-0.11.1 → lintrunner-0.12.2}/tests/snapshots/integration_test__simple_linter_two_configs.snap +0 -0
  63. {lintrunner-0.11.1 → lintrunner-0.12.2}/tests/snapshots/integration_test__skip_nonexistent_linter.snap +0 -0
  64. {lintrunner-0.11.1 → lintrunner-0.12.2}/tests/snapshots/integration_test__take_nonexistent_linter.snap +0 -0
  65. {lintrunner-0.11.1 → lintrunner-0.12.2}/tests/snapshots/integration_test__tee_json.snap +0 -0
  66. {lintrunner-0.11.1 → lintrunner-0.12.2}/tests/snapshots/integration_test__unknown_config_fails.snap +0 -0
  67. {lintrunner-0.11.1 → lintrunner-0.12.2}/tools/convert_to_sarif.py +0 -0
  68. {lintrunner-0.11.1 → lintrunner-0.12.2}/tools/convert_to_sarif_test.py +0 -0
@@ -2,6 +2,29 @@
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
+
12
+ ## [0.12.0] - 2024-02-10
13
+
14
+ ### Bug Fixes
15
+
16
+ - Properly fail if --get_paths cmd fails ([53c4961](https://github.com/suo/lintrunner/commit/53c496184eac9545e83d6a2714adf0bc1457316c))
17
+ - Dont panic when no linters are specified ([0527cf0](https://github.com/suo/lintrunner/commit/0527cf0792956a88a5fb2454688c975d0a8c8baf))
18
+ - Make --all-files work with sl ([2df4572](https://github.com/suo/lintrunner/commit/2df4572ddf1a630889a0150ac8e6bf9d63340839))
19
+
20
+ ### Features
21
+
22
+ - Add a list subcommand to show available linters ([0765237](https://github.com/suo/lintrunner/commit/0765237900aaa7e0ecb3491227b073fa72216b36))
23
+
24
+ ### Testing
25
+
26
+ - Fix snapshot test ([7c345da](https://github.com/suo/lintrunner/commit/7c345da7342aca42645cab8551ef232581083f11))
27
+
5
28
  ## [0.11.1] - 2024-01-30
6
29
 
7
30
  ### Bug Fixes
@@ -28,9 +28,9 @@ dependencies = [
28
28
 
29
29
  [[package]]
30
30
  name = "anstyle"
31
- version = "1.0.5"
31
+ version = "1.0.6"
32
32
  source = "registry+https://github.com/rust-lang/crates.io-index"
33
- checksum = "2faccea4cc4ab4a667ce676a30e8ec13922a692c99bb8f5b11f1502c72e04220"
33
+ checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc"
34
34
 
35
35
  [[package]]
36
36
  name = "anyhow"
@@ -144,9 +144,9 @@ checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec"
144
144
 
145
145
  [[package]]
146
146
  name = "bytemuck"
147
- version = "1.14.1"
147
+ version = "1.14.3"
148
148
  source = "registry+https://github.com/rust-lang/crates.io-index"
149
- checksum = "ed2490600f404f2b94c167e31d3ed1d5f3c225a0f3b80230053b3e0b7b962bd9"
149
+ checksum = "a2ef034f05691a48569bd920a96c81b9d91bbad1ab5ac7c4616c1f6ef36cb79f"
150
150
 
151
151
  [[package]]
152
152
  name = "cc"
@@ -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"
@@ -378,7 +378,7 @@ dependencies = [
378
378
  "atomic",
379
379
  "pear",
380
380
  "serde",
381
- "toml 0.8.8",
381
+ "toml 0.8.10",
382
382
  "uncased",
383
383
  "version_check",
384
384
  ]
@@ -439,15 +439,15 @@ dependencies = [
439
439
 
440
440
  [[package]]
441
441
  name = "hermit-abi"
442
- version = "0.3.4"
442
+ version = "0.3.5"
443
443
  source = "registry+https://github.com/rust-lang/crates.io-index"
444
- checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f"
444
+ checksum = "d0c62115964e08cb8039170eb33c1d0e2388a256930279edca206fff675f82c3"
445
445
 
446
446
  [[package]]
447
447
  name = "iana-time-zone"
448
- version = "0.1.59"
448
+ version = "0.1.60"
449
449
  source = "registry+https://github.com/rust-lang/crates.io-index"
450
- checksum = "b6a67363e2aa4443928ce15e57ebae94fd8949958fd1223c4cfc0cd473ad7539"
450
+ checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141"
451
451
  dependencies = [
452
452
  "android_system_properties",
453
453
  "core-foundation-sys",
@@ -478,9 +478,9 @@ dependencies = [
478
478
 
479
479
  [[package]]
480
480
  name = "indexmap"
481
- version = "2.2.1"
481
+ version = "2.2.2"
482
482
  source = "registry+https://github.com/rust-lang/crates.io-index"
483
- checksum = "433de089bd45971eecf4668ee0ee8f4cec17db4f8bd8f7bc3197a6ce37aa7d9b"
483
+ checksum = "824b2ae422412366ba479e8111fd301f7b5faece8149317bb81925979a53f520"
484
484
  dependencies = [
485
485
  "equivalent",
486
486
  "hashbrown 0.14.3",
@@ -522,12 +522,12 @@ dependencies = [
522
522
 
523
523
  [[package]]
524
524
  name = "is-terminal"
525
- version = "0.4.10"
525
+ version = "0.4.12"
526
526
  source = "registry+https://github.com/rust-lang/crates.io-index"
527
- checksum = "0bad00257d07be169d870ab665980b06cdb366d792ad690bf2e76876dc503455"
527
+ checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b"
528
528
  dependencies = [
529
- "hermit-abi 0.3.4",
530
- "rustix",
529
+ "hermit-abi 0.3.5",
530
+ "libc",
531
531
  "windows-sys",
532
532
  ]
533
533
 
@@ -548,9 +548,9 @@ checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c"
548
548
 
549
549
  [[package]]
550
550
  name = "js-sys"
551
- version = "0.3.67"
551
+ version = "0.3.68"
552
552
  source = "registry+https://github.com/rust-lang/crates.io-index"
553
- checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1"
553
+ checksum = "406cda4b368d531c842222cf9d2600a9a4acce8d29423695379c6868a143a9ee"
554
554
  dependencies = [
555
555
  "wasm-bindgen",
556
556
  ]
@@ -563,9 +563,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
563
563
 
564
564
  [[package]]
565
565
  name = "libc"
566
- version = "0.2.152"
566
+ version = "0.2.153"
567
567
  source = "registry+https://github.com/rust-lang/crates.io-index"
568
- checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7"
568
+ checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
569
569
 
570
570
  [[package]]
571
571
  name = "libredox"
@@ -586,7 +586,7 @@ checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"
586
586
 
587
587
  [[package]]
588
588
  name = "lintrunner"
589
- version = "0.11.1"
589
+ version = "0.12.2"
590
590
  dependencies = [
591
591
  "anyhow",
592
592
  "assert_cmd",
@@ -634,9 +634,9 @@ checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149"
634
634
 
635
635
  [[package]]
636
636
  name = "num-traits"
637
- version = "0.2.17"
637
+ version = "0.2.18"
638
638
  source = "registry+https://github.com/rust-lang/crates.io-index"
639
- checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c"
639
+ checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a"
640
640
  dependencies = [
641
641
  "autocfg",
642
642
  ]
@@ -684,9 +684,9 @@ dependencies = [
684
684
 
685
685
  [[package]]
686
686
  name = "pest"
687
- version = "2.7.6"
687
+ version = "2.7.7"
688
688
  source = "registry+https://github.com/rust-lang/crates.io-index"
689
- checksum = "1f200d8d83c44a45b21764d1916299752ca035d15ecd46faca3e9a2a2bf6ad06"
689
+ checksum = "219c0dcc30b6a27553f9cc242972b67f75b60eb0db71f0b5462f38b058c41546"
690
690
  dependencies = [
691
691
  "memchr",
692
692
  "thiserror",
@@ -695,9 +695,9 @@ dependencies = [
695
695
 
696
696
  [[package]]
697
697
  name = "pest_derive"
698
- version = "2.7.6"
698
+ version = "2.7.7"
699
699
  source = "registry+https://github.com/rust-lang/crates.io-index"
700
- checksum = "bcd6ab1236bbdb3a49027e920e693192ebfe8913f6d60e294de57463a493cfde"
700
+ checksum = "22e1288dbd7786462961e69bfd4df7848c1e37e8b74303dbdab82c3a9cdd2809"
701
701
  dependencies = [
702
702
  "pest",
703
703
  "pest_generator",
@@ -705,9 +705,9 @@ dependencies = [
705
705
 
706
706
  [[package]]
707
707
  name = "pest_generator"
708
- version = "2.7.6"
708
+ version = "2.7.7"
709
709
  source = "registry+https://github.com/rust-lang/crates.io-index"
710
- checksum = "2a31940305ffc96863a735bef7c7994a00b325a7138fdbc5bda0f1a0476d3275"
710
+ checksum = "1381c29a877c6d34b8c176e734f35d7f7f5b3adaefe940cb4d1bb7af94678e2e"
711
711
  dependencies = [
712
712
  "pest",
713
713
  "pest_meta",
@@ -718,9 +718,9 @@ dependencies = [
718
718
 
719
719
  [[package]]
720
720
  name = "pest_meta"
721
- version = "2.7.6"
721
+ version = "2.7.7"
722
722
  source = "registry+https://github.com/rust-lang/crates.io-index"
723
- checksum = "a7ff62f5259e53b78d1af898941cdcdccfae7385cf7d793a6e55de5d05bb4b7d"
723
+ checksum = "d0934d6907f148c22a3acbda520c7eed243ad7487a30f51f6ce52b58b7077a8a"
724
724
  dependencies = [
725
725
  "once_cell",
726
726
  "pest",
@@ -860,9 +860,9 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f"
860
860
 
861
861
  [[package]]
862
862
  name = "rustix"
863
- version = "0.38.30"
863
+ version = "0.38.31"
864
864
  source = "registry+https://github.com/rust-lang/crates.io-index"
865
- checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca"
865
+ checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949"
866
866
  dependencies = [
867
867
  "bitflags 2.4.2",
868
868
  "errno",
@@ -976,13 +976,12 @@ dependencies = [
976
976
 
977
977
  [[package]]
978
978
  name = "tempfile"
979
- version = "3.9.0"
979
+ version = "3.10.0"
980
980
  source = "registry+https://github.com/rust-lang/crates.io-index"
981
- checksum = "01ce4141aa927a6d1bd34a041795abd0db1cccba5d5f24b009f694bdf3a1f3fa"
981
+ checksum = "a365e8cd18e44762ef95d87f284f4b5cd04107fec2ff3052bd6a3e6069669e67"
982
982
  dependencies = [
983
983
  "cfg-if",
984
984
  "fastrand",
985
- "redox_syscall",
986
985
  "rustix",
987
986
  "windows-sys",
988
987
  ]
@@ -1061,9 +1060,9 @@ dependencies = [
1061
1060
 
1062
1061
  [[package]]
1063
1062
  name = "toml"
1064
- version = "0.8.8"
1063
+ version = "0.8.10"
1065
1064
  source = "registry+https://github.com/rust-lang/crates.io-index"
1066
- checksum = "a1a195ec8c9da26928f773888e0742ca3ca1040c6cd859c919c9f59c1954ab35"
1065
+ checksum = "9a9aad4a3066010876e8dcf5a8a06e70a558751117a145c6ce2b82c2e2054290"
1067
1066
  dependencies = [
1068
1067
  "serde",
1069
1068
  "serde_spanned",
@@ -1082,11 +1081,11 @@ dependencies = [
1082
1081
 
1083
1082
  [[package]]
1084
1083
  name = "toml_edit"
1085
- version = "0.21.0"
1084
+ version = "0.22.4"
1086
1085
  source = "registry+https://github.com/rust-lang/crates.io-index"
1087
- checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03"
1086
+ checksum = "0c9ffdf896f8daaabf9b66ba8e77ea1ed5ed0f72821b398aba62352e95062951"
1088
1087
  dependencies = [
1089
- "indexmap 2.2.1",
1088
+ "indexmap 2.2.2",
1090
1089
  "serde",
1091
1090
  "serde_spanned",
1092
1091
  "toml_datetime",
@@ -1155,9 +1154,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
1155
1154
 
1156
1155
  [[package]]
1157
1156
  name = "wasm-bindgen"
1158
- version = "0.2.90"
1157
+ version = "0.2.91"
1159
1158
  source = "registry+https://github.com/rust-lang/crates.io-index"
1160
- checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406"
1159
+ checksum = "c1e124130aee3fb58c5bdd6b639a0509486b0338acaaae0c84a5124b0f588b7f"
1161
1160
  dependencies = [
1162
1161
  "cfg-if",
1163
1162
  "wasm-bindgen-macro",
@@ -1165,9 +1164,9 @@ dependencies = [
1165
1164
 
1166
1165
  [[package]]
1167
1166
  name = "wasm-bindgen-backend"
1168
- version = "0.2.90"
1167
+ version = "0.2.91"
1169
1168
  source = "registry+https://github.com/rust-lang/crates.io-index"
1170
- checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd"
1169
+ checksum = "c9e7e1900c352b609c8488ad12639a311045f40a35491fb69ba8c12f758af70b"
1171
1170
  dependencies = [
1172
1171
  "bumpalo",
1173
1172
  "log",
@@ -1180,9 +1179,9 @@ dependencies = [
1180
1179
 
1181
1180
  [[package]]
1182
1181
  name = "wasm-bindgen-macro"
1183
- version = "0.2.90"
1182
+ version = "0.2.91"
1184
1183
  source = "registry+https://github.com/rust-lang/crates.io-index"
1185
- checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999"
1184
+ checksum = "b30af9e2d358182b5c7449424f017eba305ed32a7010509ede96cdc4696c46ed"
1186
1185
  dependencies = [
1187
1186
  "quote",
1188
1187
  "wasm-bindgen-macro-support",
@@ -1190,9 +1189,9 @@ dependencies = [
1190
1189
 
1191
1190
  [[package]]
1192
1191
  name = "wasm-bindgen-macro-support"
1193
- version = "0.2.90"
1192
+ version = "0.2.91"
1194
1193
  source = "registry+https://github.com/rust-lang/crates.io-index"
1195
- checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7"
1194
+ checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66"
1196
1195
  dependencies = [
1197
1196
  "proc-macro2",
1198
1197
  "quote",
@@ -1203,9 +1202,9 @@ dependencies = [
1203
1202
 
1204
1203
  [[package]]
1205
1204
  name = "wasm-bindgen-shared"
1206
- version = "0.2.90"
1205
+ version = "0.2.91"
1207
1206
  source = "registry+https://github.com/rust-lang/crates.io-index"
1208
- checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b"
1207
+ checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838"
1209
1208
 
1210
1209
  [[package]]
1211
1210
  name = "winapi"
@@ -1315,9 +1314,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04"
1315
1314
 
1316
1315
  [[package]]
1317
1316
  name = "winnow"
1318
- version = "0.5.35"
1317
+ version = "0.5.39"
1319
1318
  source = "registry+https://github.com/rust-lang/crates.io-index"
1320
- checksum = "1931d78a9c73861da0134f453bb1f790ce49b2e30eba8410b4b79bac72b46a2d"
1319
+ checksum = "5389a154b01683d28c77f8f68f49dea75f0a4da32557a58f68ee51ebba472d29"
1321
1320
  dependencies = [
1322
1321
  "memchr",
1323
1322
  ]
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "lintrunner"
3
- version = "0.11.1"
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.11.1
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")
@@ -145,6 +145,30 @@ impl version_control::System for Repo {
145
145
  .collect::<Vec<AbsPath>>();
146
146
  Ok(filtered_files)
147
147
  }
148
+
149
+ fn get_all_files(&self, _under: Option<&AbsPath>) -> Result<Vec<AbsPath>> {
150
+ let output = Command::new("git")
151
+ .arg("grep")
152
+ .arg("-Il")
153
+ .arg(".")
154
+ .current_dir(&self.root)
155
+ .output()?;
156
+
157
+ ensure_output("git grep -Il", &output)?;
158
+
159
+ let files =
160
+ std::str::from_utf8(&output.stdout).context("failed to parse paths_cmd output")?;
161
+ let files = files
162
+ .lines()
163
+ .map(|s| s.to_string())
164
+ .collect::<HashSet<String>>();
165
+ let mut files = files.into_iter().collect::<Vec<String>>();
166
+ files.sort();
167
+ files
168
+ .into_iter()
169
+ .map(AbsPath::try_from)
170
+ .collect::<Result<_>>()
171
+ }
148
172
  }
149
173
 
150
174
  pub fn get_paths_from_cmd(paths_cmd: &str) -> Result<Vec<AbsPath>> {
@@ -162,6 +186,11 @@ pub fn get_paths_from_cmd(paths_cmd: &str) -> Result<Vec<AbsPath>> {
162
186
  .output()
163
187
  .context("failed to run provided paths_cmd")?;
164
188
 
189
+ ensure!(
190
+ output.status.success(),
191
+ format!("Failed to run provided paths_cmd: '{}'", paths_cmd)
192
+ );
193
+
165
194
  let files = std::str::from_utf8(&output.stdout).context("failed to parse paths_cmd output")?;
166
195
  let files = files
167
196
  .lines()
@@ -331,6 +360,12 @@ mod tests {
331
360
  Ok(())
332
361
  }
333
362
 
363
+ #[test]
364
+ fn invalid_get_paths_from_cmd_fails() -> () {
365
+ assert!(get_paths_from_cmd("asoidjfoaisdjf").is_err());
366
+ assert!(get_paths_from_cmd("false").is_err());
367
+ }
368
+
334
369
  #[test]
335
370
  fn merge_base_with() -> Result<()> {
336
371
  let git = GitCheckout::new()?;
@@ -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,18 @@ 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()?;
178
+ let mut stdout = Term::stdout();
179
+ if linters.is_empty() {
180
+ stdout.write_line("No linters ran.")?;
181
+ return Ok(0);
182
+ }
183
+
184
+ let config_dir = if only_lint_under_config_dir {
185
+ Some(AbsPath::try_from(linters[0].get_config_dir())?)
186
+ } else {
187
+ None
188
+ };
168
189
 
169
190
  let mut files = match paths_opt {
170
191
  PathsOpt::Auto => {
@@ -181,20 +202,18 @@ pub fn do_lint(
181
202
  PathsOpt::PathsCmd(paths_cmd) => get_paths_from_cmd(&paths_cmd)?,
182
203
  PathsOpt::Paths(paths) => get_paths_from_input(paths)?,
183
204
  PathsOpt::PathsFile(file) => get_paths_from_file(file)?,
184
- PathsOpt::AllFiles => get_paths_from_cmd("git grep -Il .")?,
205
+ PathsOpt::AllFiles => repo.get_all_files(config_dir.as_ref())?,
185
206
  };
186
207
 
187
208
  // Sort and unique the files so we pass a consistent ordering to linters
188
- files.sort();
189
- files.dedup();
190
-
191
- if only_lint_under_config_dir {
192
- let config_dir = linters[0].get_config_dir();
209
+ if let Some(config_dir) = config_dir {
193
210
  files = files
194
211
  .into_iter()
195
- .filter(|path| path.starts_with(config_dir))
212
+ .filter(|path| path.starts_with(&config_dir))
196
213
  .collect();
197
214
  }
215
+ files.sort();
216
+ files.dedup();
198
217
 
199
218
  let files = Arc::new(files);
200
219
 
@@ -261,8 +280,6 @@ pub fn do_lint(
261
280
  // Flush the logger before rendering results.
262
281
  log::logger().flush();
263
282
 
264
- let mut stdout = Term::stdout();
265
-
266
283
  let did_print = match render_opt {
267
284
  RenderOpt::Default => render_lint_messages(&mut stdout, &all_lints)?,
268
285
  RenderOpt::Json => render_lint_messages_json(&mut stdout, &all_lints)?,
@@ -67,11 +67,15 @@ struct Args {
67
67
  #[clap(long, short, conflicts_with_all=&["paths", "paths-cmd", "paths-from", "revision"], global = true)]
68
68
  merge_base_with: Option<String>,
69
69
 
70
- /// Comma-separated list of linters to skip (e.g. --skip CLANGFORMAT,NOQA)
70
+ /// Comma-separated list of linters to skip (e.g. --skip CLANGFORMAT,NOQA).
71
+ ///
72
+ /// You can run: `lintrunner list` to see available linters.
71
73
  #[clap(long, global = true)]
72
74
  skip: Option<String>,
73
75
 
74
- /// Comma-separated list of linters to run (opposite of --skip)
76
+ /// Comma-separated list of linters to run (opposite of --skip).
77
+ ///
78
+ /// You can run: `lintrunner list` to see available linters.
75
79
  #[clap(long, global = true)]
76
80
  take: Option<String>,
77
81
 
@@ -129,6 +133,9 @@ enum SubCommand {
129
133
  /// Run linters. This is the default if no subcommand is provided.
130
134
  Lint,
131
135
 
136
+ /// Show the list of available linters, based on this repo's .lintrunner.toml.
137
+ List,
138
+
132
139
  /// Create a bug report for a past invocation of lintrunner.
133
140
  Rage {
134
141
  /// Choose a specific invocation to report on. 0 is the most recent run.
@@ -183,8 +190,6 @@ fn do_main() -> Result<i32> {
183
190
  debug!("Version: {VERSION}");
184
191
  debug!("Passed args: {:?}", std::env::args());
185
192
  debug!("Computed args: {:?}", args);
186
- let repo = version_control::Repo::new()?;
187
- debug!("Current rev: {}", repo.get_head()?);
188
193
 
189
194
  // report config paths which do not exist
190
195
  for path in &config_paths {
@@ -286,7 +291,6 @@ fn do_main() -> Result<i32> {
286
291
  SubCommand::Format => {
287
292
  check_init_changed(&persistent_data_store, &lint_runner_config)?;
288
293
  do_lint(
289
- &repo,
290
294
  linters,
291
295
  paths_opt,
292
296
  true, // always apply patches when we use the format command
@@ -301,7 +305,6 @@ fn do_main() -> Result<i32> {
301
305
  // Default command is to just lint.
302
306
  check_init_changed(&persistent_data_store, &lint_runner_config)?;
303
307
  do_lint(
304
- &repo,
305
308
  linters,
306
309
  paths_opt,
307
310
  args.apply_patches,
@@ -313,6 +316,13 @@ fn do_main() -> Result<i32> {
313
316
  )
314
317
  }
315
318
  SubCommand::Rage { invocation } => do_rage(&persistent_data_store, invocation),
319
+ SubCommand::List => {
320
+ println!("Available linters:");
321
+ for linter in &lint_runner_config.linters {
322
+ println!(" {}", linter.code);
323
+ }
324
+ Ok(0)
325
+ }
316
326
  };
317
327
 
318
328
  let exit_info = match &res {
@@ -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,4 +1,8 @@
1
- use crate::{log_utils, path, version_control};
1
+ use crate::{
2
+ log_utils,
3
+ path::{self, AbsPath},
4
+ version_control::VersionControl,
5
+ };
2
6
 
3
7
  use anyhow;
4
8
 
@@ -6,7 +10,7 @@ pub struct Repo {
6
10
  root: path::AbsPath,
7
11
  }
8
12
 
9
- impl version_control::System for Repo {
13
+ impl VersionControl for Repo {
10
14
  fn new() -> anyhow::Result<Self> {
11
15
  let output = std::process::Command::new("sl").arg("root").output()?;
12
16
  anyhow::ensure!(output.status.success(), "Failed to determine Sapling root");
@@ -41,6 +45,44 @@ impl version_control::System for Repo {
41
45
  Ok(merge_base.to_string())
42
46
  }
43
47
 
48
+ fn get_all_files(&self, under: Option<&AbsPath>) -> anyhow::Result<Vec<AbsPath>> {
49
+ // Output of sl status looks like:
50
+ // D src/lib.rs
51
+ // M foo/bar.baz
52
+ let re = regex::Regex::new(r"^[A-Z?]\s+")?;
53
+
54
+ let mut cmd = std::process::Command::new("sl");
55
+ cmd.arg("status").arg("--all");
56
+ if let Some(under) = under {
57
+ cmd.arg(under.as_os_str());
58
+ }
59
+ cmd.current_dir(&self.root);
60
+ let output = cmd.output()?;
61
+ log_utils::ensure_output(&format!("{:?}", cmd), &output)?;
62
+ let all_files_str = std::str::from_utf8(&output.stdout)?;
63
+ let all_files: std::collections::HashSet<String> = all_files_str
64
+ .split('\n')
65
+ .map(|x| x.to_string())
66
+ .filter(|line| !line.starts_with('I'))
67
+ .map(|line| re.replace(&line, "").to_string())
68
+ .filter(|line| !line.is_empty())
69
+ .collect();
70
+
71
+ let filtered_all_files = all_files
72
+ .into_iter()
73
+ .map(|f| format!("{}", self.root.join(f).display()))
74
+ .filter_map(|f| match path::AbsPath::try_from(&f) {
75
+ Ok(abs_path) => Some(abs_path),
76
+ Err(_) => {
77
+ eprintln!("Failed to find file while gathering files to lint: {}", f);
78
+ None
79
+ }
80
+ })
81
+ .collect::<Vec<path::AbsPath>>();
82
+
83
+ Ok(filtered_all_files)
84
+ }
85
+
44
86
  fn get_changed_files(&self, relative_to: Option<&str>) -> anyhow::Result<Vec<path::AbsPath>> {
45
87
  // Output of sl status looks like:
46
88
  // D src/lib.rs
@@ -175,7 +217,6 @@ mod tests {
175
217
  fn changed_files(&self, relative_to: Option<&str>) -> Result<Vec<String>> {
176
218
  let _shared = SL_GLOBAL_MUTEX.lock().unwrap();
177
219
  std::env::set_current_dir(&self.root)?;
178
- use version_control::System;
179
220
  let repo = Repo::new()?;
180
221
  let files = repo.get_changed_files(relative_to)?;
181
222
  let files = files
@@ -188,10 +229,16 @@ mod tests {
188
229
  fn merge_base_with(&self, merge_base_with: &str) -> Result<String> {
189
230
  let _shared = SL_GLOBAL_MUTEX.lock().unwrap();
190
231
  std::env::set_current_dir(&self.root)?;
191
- use version_control::System;
192
232
  let repo = Repo::new()?;
193
233
  repo.get_merge_base_with(merge_base_with)
194
234
  }
235
+
236
+ fn get_all_files(&self) -> Result<Vec<AbsPath>> {
237
+ let _shared = SL_GLOBAL_MUTEX.lock().unwrap();
238
+ std::env::set_current_dir(&self.root)?;
239
+ let repo = Repo::new()?;
240
+ repo.get_all_files(None)
241
+ }
195
242
  }
196
243
 
197
244
  // Should properly detect changes in the commit (and not check other files)
@@ -374,6 +421,34 @@ mod tests {
374
421
  Ok(())
375
422
  }
376
423
 
424
+ #[test]
425
+ #[cfg_attr(target_os = "windows", ignore)] // remove when sapling installation is better
426
+ #[cfg_attr(target_os = "linux", ignore)] // remove when sapling installation is better
427
+ fn get_all_files() -> Result<()> {
428
+ let git = testing::GitCheckout::new()?;
429
+ git.write_file("test_1.txt", "Initial commit")?;
430
+ git.write_file("test_2.txt", "Initial commit")?;
431
+ git.write_file("test_3.txt", "Initial commit")?;
432
+ git.write_file("test_4.txt", "Initial commit")?;
433
+
434
+ git.add(".")?;
435
+ git.commit("I am main")?;
436
+ let sl = SaplingClone::new(&git)?;
437
+ let mut all_files = sl.get_all_files()?;
438
+ all_files.sort();
439
+ assert_eq!(
440
+ all_files,
441
+ vec!(
442
+ AbsPath::try_from("README")?,
443
+ AbsPath::try_from("test_1.txt")?,
444
+ AbsPath::try_from("test_2.txt")?,
445
+ AbsPath::try_from("test_3.txt")?,
446
+ AbsPath::try_from("test_4.txt")?
447
+ )
448
+ );
449
+ Ok(())
450
+ }
451
+
377
452
  #[test]
378
453
  #[cfg_attr(target_os = "windows", ignore)] // remove when sapling installation is better
379
454
  #[cfg_attr(target_os = "linux", ignore)] // remove when sapling installation is better
@@ -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
+ }
@@ -878,3 +878,42 @@ fn linter_replacement_trailing_newlines() -> Result<()> {
878
878
 
879
879
  Ok(())
880
880
  }
881
+
882
+ #[test]
883
+ fn lint_with_no_linters() -> Result<()> {
884
+ let data_path = tempfile::tempdir()?;
885
+ let lint_message = LintMessage {
886
+ path: Some("tests/fixtures/fake_source_file.rs".to_string()),
887
+ line: Some(9),
888
+ char: Some(1),
889
+ code: "DUMMY".to_string(),
890
+ name: "dummy failure".to_string(),
891
+ severity: LintSeverity::Advice,
892
+ original: None,
893
+ replacement: None,
894
+ description: Some("A dummy linter failure".to_string()),
895
+ };
896
+ let config = temp_config(&format!(
897
+ "\
898
+ [[linter]]
899
+ code = 'TESTLINTER'
900
+ include_patterns = ['**']
901
+ command = ['echo', '{}']
902
+ ",
903
+ serde_json::to_string(&lint_message)?
904
+ ))?;
905
+
906
+ let mut cmd = Command::cargo_bin("lintrunner")?;
907
+ cmd.arg(format!("--config={}", config.path().to_str().unwrap()));
908
+ cmd.arg(format!(
909
+ "--data-path={}",
910
+ data_path.path().to_str().unwrap()
911
+ ));
912
+
913
+ // Run on a file to ensure that the linter is run.
914
+ cmd.arg("--skip=TESTLINTER");
915
+ cmd.assert().success();
916
+ assert_output_snapshot("lint_with_no_linters", &mut cmd)?;
917
+
918
+ Ok(())
919
+ }
@@ -1,11 +1,9 @@
1
1
  ---
2
2
  source: tests/integration_test.rs
3
- assertion_line: 20
4
3
  expression: output_lines
5
4
  ---
6
5
  - "STDOUT:"
7
- - ok No lint issues.
8
- - Successfully applied all patches.
6
+ - No linters ran.
9
7
  - ""
10
8
  - ""
11
9
  - "STDERR:"
@@ -0,0 +1,11 @@
1
+ ---
2
+ source: tests/integration_test.rs
3
+ expression: output_lines
4
+ ---
5
+ - "STDOUT:"
6
+ - No linters ran.
7
+ - ""
8
+ - ""
9
+ - "STDERR:"
10
+ - "WARNING: No previous init data found. If this is the first time you're running lintrunner, you should run `lintrunner init`."
11
+
@@ -1,60 +0,0 @@
1
- use crate::{git, path, sapling};
2
-
3
- use anyhow;
4
-
5
- pub struct Repo(RepoImpl);
6
-
7
- enum RepoImpl {
8
- Git(git::Repo),
9
- Sapling(sapling::Repo),
10
- }
11
-
12
- // Trait describing the operations we need in lintrunner for a version
13
- // control system.
14
- pub trait System {
15
- // Creates a new instance, trying the different implementations we
16
- // have available.
17
- fn new() -> anyhow::Result<Self>
18
- where
19
- Self: Sized;
20
-
21
- // Gets the tip of the repository.
22
- fn get_head(&self) -> anyhow::Result<String>;
23
-
24
- // Gets the most recent common ancestor between the tip and the
25
- // given commit.
26
- fn get_merge_base_with(&self, merge_base_with: &str) -> anyhow::Result<String>;
27
-
28
- // Gets the files that have changed relative to the given commit.
29
- fn get_changed_files(&self, relative_to: Option<&str>) -> anyhow::Result<Vec<path::AbsPath>>;
30
- }
31
-
32
- impl Repo {
33
- pub fn new() -> anyhow::Result<Self> {
34
- git::Repo::new()
35
- .and_then(|repo| Ok(Repo(RepoImpl::Git(repo))))
36
- .or_else(|_| sapling::Repo::new().and_then(|repo| Ok(Repo(RepoImpl::Sapling(repo)))))
37
- }
38
-
39
- pub fn get_head(&self) -> anyhow::Result<String> {
40
- self.get_system().get_head()
41
- }
42
-
43
- pub fn get_merge_base_with(&self, merge_base_with: &str) -> anyhow::Result<String> {
44
- self.get_system().get_merge_base_with(merge_base_with)
45
- }
46
-
47
- pub fn get_changed_files(
48
- &self,
49
- relative_to: Option<&str>,
50
- ) -> anyhow::Result<Vec<path::AbsPath>> {
51
- self.get_system().get_changed_files(relative_to)
52
- }
53
-
54
- fn get_system<'a>(&'a self) -> Box<&'a dyn System> {
55
- match &self.0 {
56
- RepoImpl::Git(git) => Box::new(git as &dyn System),
57
- RepoImpl::Sapling(sapling) => Box::new(sapling as &dyn System),
58
- }
59
- }
60
- }
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