Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/+easyblock-reach-header.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`easyblock-reach` heads `reach.toml` and `reach.md` with a line that says only that `eb-stack easyblock-reach` generated the file, instead of the `pr-overlap` warning about a data branch that is never merged. The report is written to `--out-dir`, and no branch holds it.
7 changes: 4 additions & 3 deletions docs/orgmode/howto/easyblock-reach.org
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ module. The empty range ~HEAD..HEAD~ on that same checkout printed
~name/version[-toolchain]versionsuffix~. Blank lines and ~#~ comments are
ignored.

The command writes ~reach.toml~, ~reach.json~, and ~reach.md~. The TOML
file starts with the generated-file header. The markdown opens with the
same warning as an HTML comment. Neither is a file to merge.
The command writes ~reach.toml~, ~reach.json~, and ~reach.md~ to
~--out-dir~. ~reach.toml~ starts with
~# Generated by `eb-stack easyblock-reach`.~, and ~reach.md~ opens with
the same line as an HTML comment. ~reach.json~ has no comment.

* A commit range or a pull request

Expand Down
7 changes: 4 additions & 3 deletions llms-full.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2710,9 +2710,10 @@ module. The empty range `HEAD..HEAD` on that same checkout printed
`name/version[-toolchain]versionsuffix`. Blank lines and `#` comments are
ignored.

The command writes `reach.toml`, `reach.json`, and `reach.md`. The TOML
file starts with the generated-file header. The markdown opens with the
same warning as an HTML comment. Neither is a file to merge.
The command writes `reach.toml`, `reach.json`, and `reach.md` to
`--out-dir`. `reach.toml` starts with
`# Generated by `eb-stack easyblock-reach`.`, and `reach.md` opens with
the same line as an HTML comment. `reach.json` has no comment.

# A commit range or a pull request

Expand Down
36 changes: 31 additions & 5 deletions src/easyblock_reach.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ fn collect_py(root: &Path, files: &mut Vec<PathBuf>) -> std::io::Result<()> {
}

/// Header on every generated TOML file.
pub const GENERATED_HEADER: &str = "# Generated by `eb-stack easyblock-reach`. Data only: the branch holding this file is\n# regenerated on every run and must never be merged.\n";
pub const GENERATED_HEADER: &str = "# Generated by `eb-stack easyblock-reach`.\n";

/// Why a reach report could not be built.
#[derive(Debug, Error)]
Expand Down Expand Up @@ -860,9 +860,7 @@ pub fn to_json(report: &ReachReport) -> Result<String, serde_json::Error> {

/// Reviewer markdown. The HTML comment marks the file as generated.
pub fn render_markdown(report: &ReachReport) -> String {
let mut out = String::from(
"<!-- Generated by `eb-stack easyblock-reach`. This branch is never merged. -->\n",
);
let mut out = String::from("<!-- Generated by `eb-stack easyblock-reach`. -->\n");
out.push_str(&format!(
"# Easyblock reach ({})\n\n{} easyconfigs, {} already installed, {} modules that depend on a hit.\n\n",
report.generated_at, report.easyconfig_count, report.installed_count, report.reverse.len()
Expand Down Expand Up @@ -1520,7 +1518,7 @@ mod tests {
toml::from_str(toml_text.trim_start_matches(GENERATED_HEADER)).unwrap();
assert_eq!(back, report);
let json = to_json(&report).unwrap();
assert!(!json.contains("never be merged"));
assert!(!json.contains("Generated by"));
let md = render_markdown(&report);
assert!(md.contains("GROMACS/2024.1"));
assert!(md.contains("wrapper/1"));
Expand All @@ -1534,6 +1532,34 @@ mod tests {
assert_eq!(installed, BTreeSet::from(["zlib/1.3".into()]));
}

/// The report is written to `--out-dir`; unlike `pr-overlap`, no data
/// branch holds it.
#[test]
fn the_generated_headers_name_no_branch() {
let report = ReachReport {
schema_version: REACH_SCHEMA_VERSION,
generated_at: "t".into(),
changed_files: Vec::new(),
changed_classes: Vec::new(),
reached_classes: Vec::new(),
easyconfig_count: 0,
installed_count: 0,
hits: Vec::new(),
reverse: Vec::new(),
skipped: Vec::new(),
};
let toml_text = to_toml(&report).unwrap();
assert_eq!(
toml_text.lines().next(),
Some("# Generated by `eb-stack easyblock-reach`.")
);
assert_eq!(
render_markdown(&report).lines().next(),
Some("<!-- Generated by `eb-stack easyblock-reach`. -->")
);
assert!(!toml_text.contains("branch"));
}

fn git_ok(dir: &std::path::Path, args: &[&str]) {
let output = std::process::Command::new("git")
.arg("-C")
Expand Down
Loading