[1/1]: Improve push comment when diff is empty#40
Merged
slinder1 merged 1 commit intoApr 16, 2026
Conversation
Owner
Author
🛠️ Initial changes (click to expand):diff --git b/src/gd.rs a/src/gd.rs
@@ -1,7 +1,7 @@
// Copyright © 2026 Advanced Micro Devices, Inc. All rights reserved.
// SPDX-License-Identifier: MIT
-use crate::change::{self, AnyChange, Change, Diff, LocalChange};
+use crate::change::{self, AnyChange, Change, LocalChange};
use crate::cli;
use crate::env;
use crate::gh::{self, Pr, PrState};
@@ -151,13 +151,7 @@ fn push(cfg: &cli::Push) -> Result<()> {
changes
.par_iter()
.zip(diffs)
- .map(|(c, diff)| {
- let (summary, body) = match diff {
- Diff::InitialDiff(text) => ("Initial changes", text),
- Diff::InterDiff(text) => ("Changes since last push", text),
- };
- c.pr.add_details_comment(summary.to_string(), format!("```diff\n{body}\n```"))
- })
+ .map(|(c, diff)| c.pr.add_details_comment(&diff))
.collect::<Result<Vec<_>>>()
.context("could not add interdiff comments")?;
changes
diff --git b/src/gh.rs a/src/gh.rs
@@ -1,7 +1,7 @@
// Copyright © 2026 Advanced Micro Devices, Inc. All rights reserved.
// SPDX-License-Identifier: MIT
-use crate::change::LocalChange;
+use crate::change::{Diff, LocalChange};
use crate::env;
use crate::util::{Extract, exec};
use anyhow::{Context, Result, bail};
@@ -144,10 +144,18 @@ impl Pr {
Ok(())
}
- pub fn add_details_comment(&self, summary: String, body: String) -> Result<()> {
- let comment = format!(
- "<details>\n<summary>🛠️ {summary} (click to expand):</summary>\n\n{body}\n</details>"
- );
+ pub fn add_details_comment(&self, diff: &Diff) -> Result<()> {
+ let (summary, changes) = match diff {
+ Diff::InitialDiff(text) => ("Initial changes", text),
+ Diff::InterDiff(text) => ("Changes since last push", text),
+ };
+ let comment = if changes.is_empty() {
+ format!("🛠️ {summary}: none (likely a rebase)")
+ } else {
+ format!(
+ "<details>\n<summary>🛠️ {summary} (click to expand):</summary>\n\n```diff\n{changes}\n```\n</details>"
+ )
+ };
let mut body_arg = ArgInlineOrFile::new("body");
let mut cmd = gh();
let args = self.args_for("comment", [body_arg.arg(comment)?]);
|
cd2c423 to
8569e55
Compare
Owner
Author
🛠️ Changes since last push (click to expand): |
Change-Id: I1125aa8a0ac19d682ddc1db1f2e5a837f1a35a4f
8569e55 to
02cdd71
Compare
Owner
Author
|
🛠️ Changes since last push: none (likely a rebase) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change-Id: I1125aa8a0ac19d682ddc1db1f2e5a837f1a35a4f
Stack:
main(Note: Closed and merged PRs may not be reflected here and PR numbering is not stable.)