Skip to content

Commit 952d266

Browse files
authored
github: allow disabling github annotations in upload subcommand (#590)
1 parent 256e5b0 commit 952d266

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

crates/squawk/src/github.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ pub fn check_and_comment_on_pr(
7878
exclude_paths: &[String],
7979
pg_version: Option<Version>,
8080
assume_in_transaction: bool,
81+
github_annotations: bool,
8182
) -> Result<()> {
8283
let UploadToGithubArgs {
8384
paths,
@@ -136,9 +137,11 @@ pub fn check_and_comment_on_pr(
136137
COMMENT_HEADER,
137138
)?;
138139

139-
let stdout = io::stdout();
140-
let mut handle = stdout.lock();
141-
fmt_github_annotations(&mut handle, &file_results)?;
140+
if github_annotations {
141+
let stdout = io::stdout();
142+
let mut handle = stdout.lock();
143+
fmt_github_annotations(&mut handle, &file_results)?;
144+
}
142145

143146
let violations: usize = file_results.iter().map(|f| f.violations.len()).sum();
144147

crates/squawk/src/main.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ Please open an issue at https://github.com/sbdchd/squawk/issues/new with the log
216216

217217
let mut clap_app = Opt::clap();
218218
let is_stdin = !atty::is(Stream::Stdin);
219+
let github_annotations = std::env::var("GITHUB_ACTIONS").is_ok()
220+
&& !std::env::var("SQUAWK_DISABLE_GITHUB_ANNOTATIONS").is_ok();
219221
match opts.cmd {
220222
Some(Command::Server) => {
221223
squawk_server::run().context("language server failed")?;
@@ -230,6 +232,7 @@ Please open an issue at https://github.com/sbdchd/squawk/issues/new with the log
230232
&excluded_paths,
231233
pg_version,
232234
assume_in_transaction,
235+
github_annotations,
233236
)
234237
.context("Upload to GitHub failed")?;
235238
}
@@ -255,8 +258,6 @@ Please open an issue at https://github.com/sbdchd/squawk/issues/new with the log
255258
debug(&mut handle, &found_paths, read_stdin, &kind, opts.verbose)?;
256259
} else {
257260
let reporter = opts.reporter.unwrap_or(Reporter::Tty);
258-
let github_annotations = std::env::var("GITHUB_ACTIONS").is_ok()
259-
&& !std::env::var("SQUAWK_DISABLE_GITHUB_ANNOTATIONS").is_ok();
260261
let exit_code = check_and_dump_files(
261262
&mut handle,
262263
&found_paths,

0 commit comments

Comments
 (0)