Skip to content

Commit badba09

Browse files
authored
build: bump git-bot-feedback to v0.6.1 (#363)
Moves some much needed logic downstream into git-bot-feedback: `FileFilter::walk_dir()` better supports absolute paths by stripping `repo_root` paths prefixed to the returned results. Also applied to a given relative `root_path`. Also removes a redundant patch to `get_changed_files()`. The results returned there are already relative to the repo root, so there's no need to strip a prefixed path that isn't there. follow-up to #349
1 parent cec2704 commit badba09

6 files changed

Lines changed: 9 additions & 32 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cpp-linter/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ thiserror = { workspace = true }
3333
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
3434

3535
[dependencies.git-bot-feedback]
36-
version = "0.5.6"
36+
version = "0.6.1"
3737
features = ["file-changes"]
3838
# path = "../../git-bot-feedback"
3939
# git = "https://github.com/2bndy5/git-bot-feedback"

cpp-linter/src/git.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ mod test {
1111
use std::{
1212
env::{self, current_dir, set_current_dir},
1313
fs,
14-
path::PathBuf,
1514
process::Command,
1615
};
1716

@@ -104,7 +103,6 @@ mod test {
104103
&LinesChangedOnly::Off.into(),
105104
&base_diff,
106105
ignore_staged,
107-
&PathBuf::from("."),
108106
)
109107
.await
110108
.unwrap()

cpp-linter/src/rest_client.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use std::{
44
env,
5-
path::{Path, PathBuf},
5+
path::PathBuf,
66
sync::{Arc, Mutex},
77
};
88

@@ -69,7 +69,6 @@ impl RestClient {
6969
lines_changed_only: &LinesChangedOnly,
7070
base_diff: &Option<String>,
7171
ignore_index: bool,
72-
repo_root: &Path,
7372
) -> Result<Vec<FileObj>, ClientError> {
7473
let files = self
7574
.client
@@ -89,14 +88,7 @@ impl RestClient {
8988
.map(|hunk| hunk.start..=hunk.end)
9089
.collect();
9190
let file_path = PathBuf::from(file_name);
92-
FileObj::from(
93-
file_path
94-
.strip_prefix(repo_root)
95-
.map(PathBuf::from)
96-
.unwrap_or(file_path),
97-
diff_lines.added_lines.clone(),
98-
diff_chunks,
99-
)
91+
FileObj::from(file_path, diff_lines.added_lines.clone(), diff_chunks)
10092
})
10193
.collect())
10294
}

cpp-linter/src/run.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ pub async fn run_main(args: Vec<String>) -> Result<()> {
8282
.collect::<Vec<&str>>(),
8383
None,
8484
);
85-
file_filter.parse_submodules();
85+
let gitmodules = cli.source_options.repo_root.join(".gitmodules");
86+
file_filter.parse_submodules(Some(gitmodules.as_path()));
8687
if let Some(files) = &cli.not_ignored {
8788
file_filter.not_ignored.extend(files.clone());
8889
}
@@ -101,7 +102,6 @@ pub async fn run_main(args: Vec<String>) -> Result<()> {
101102
}
102103

103104
rest_api_client.start_log_group("Get list of specified source files");
104-
let repo_root_path = PathBuf::from(&cli.source_options.repo_root);
105105
let files = if !matches!(cli.source_options.lines_changed_only, LinesChangedOnly::Off)
106106
|| cli.source_options.files_changed_only
107107
{
@@ -112,7 +112,6 @@ pub async fn run_main(args: Vec<String>) -> Result<()> {
112112
&cli.source_options.lines_changed_only.clone().into(),
113113
&cli.source_options.diff_base,
114114
cli.source_options.ignore_index,
115-
&repo_root_path,
116115
)
117116
.await?
118117
} else {
@@ -122,12 +121,7 @@ pub async fn run_main(args: Vec<String>) -> Result<()> {
122121
.into_iter()
123122
.map(|file_name| {
124123
let file_path = PathBuf::from(&file_name);
125-
FileObj::new(
126-
file_path
127-
.strip_prefix(&repo_root_path)
128-
.map(PathBuf::from)
129-
.unwrap_or(file_path),
130-
)
124+
FileObj::new(file_path)
131125
})
132126
.collect();
133127
if is_pr && (cli.feedback_options.tidy_review || cli.feedback_options.format_review) {
@@ -137,7 +131,6 @@ pub async fn run_main(args: Vec<String>) -> Result<()> {
137131
&LinesChangedOnly::Off.into(),
138132
&cli.source_options.diff_base,
139133
cli.source_options.ignore_index,
140-
&repo_root_path,
141134
)
142135
.await?;
143136
for changed_file in changed_files {

cpp-linter/tests/paginated_changed_files.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,7 @@ async fn get_paginated_changes(lib_root: &Path, tmp_dir: &TempDir, test_params:
138138

139139
let file_filter = FileFilter::new(&[], &["cpp", "hpp"], None);
140140
let files = client
141-
.get_list_of_changed_files(
142-
&file_filter,
143-
&LinesChangedOnly::Off,
144-
&None::<String>,
145-
false,
146-
tmp_dir.path(),
147-
)
141+
.get_list_of_changed_files(&file_filter, &LinesChangedOnly::Off, &None::<String>, false)
148142
.await;
149143
match files {
150144
Err(e) => {

0 commit comments

Comments
 (0)