diff --git a/Cargo.lock b/Cargo.lock index 763aa8b..dd1fa0a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -564,7 +564,7 @@ dependencies = [ [[package]] name = "comline-codegen" version = "0.1.0" -source = "git+https://github.com/ComlineProject/generation?rev=58ff61b4a72a2bcdba6685809e615ffb614e1d8e#58ff61b4a72a2bcdba6685809e615ffb614e1d8e" +source = "git+https://github.com/ComlineProject/generation?rev=9b8336e4acd0a1f10b75aa851c36571f4e1d0d47#9b8336e4acd0a1f10b75aa851c36571f4e1d0d47" dependencies = [ "comline-core", "eyre", @@ -578,7 +578,7 @@ dependencies = [ [[package]] name = "comline-codegen-rust" version = "0.1.0" -source = "git+https://github.com/ComlineProject/comline-rust?rev=52e0eadf1c424f9486ee97d75d74cf59bbc1f191#52e0eadf1c424f9486ee97d75d74cf59bbc1f191" +source = "git+https://github.com/ComlineProject/comline-rust?rev=89530a72f37180517e1c70f88437b1bedf1e703a#89530a72f37180517e1c70f88437b1bedf1e703a" dependencies = [ "comline-codegen", "comline-core", @@ -588,7 +588,7 @@ dependencies = [ [[package]] name = "comline-codegen-typescript" version = "0.1.0" -source = "git+https://github.com/ComlineProject/comline-typescript?rev=932edaad1fd0a0dba47f8fff132149e03c0340dc#932edaad1fd0a0dba47f8fff132149e03c0340dc" +source = "git+https://github.com/ComlineProject/comline-typescript?rev=82447d54a8616a1ed37e4a7886df25deb2af7baf#82447d54a8616a1ed37e4a7886df25deb2af7baf" dependencies = [ "comline-codegen", "comline-core", @@ -598,7 +598,7 @@ dependencies = [ [[package]] name = "comline-core" version = "0.1.0" -source = "git+https://github.com/ComlineProject/core?rev=076cae0c3a0639b0c083b61a94f9d4913e853b3f#076cae0c3a0639b0c083b61a94f9d4913e853b3f" +source = "git+https://github.com/ComlineProject/core?rev=2be483f5adc303bd39c76e11f930ec2340eee57a#2be483f5adc303bd39c76e11f930ec2340eee57a" dependencies = [ "ariadne", "blake3", @@ -627,12 +627,12 @@ dependencies = [ [[package]] name = "comline-core-stdlib" version = "0.1.0" -source = "git+https://github.com/ComlineProject/core?rev=076cae0c3a0639b0c083b61a94f9d4913e853b3f#076cae0c3a0639b0c083b61a94f9d4913e853b3f" +source = "git+https://github.com/ComlineProject/core?rev=2be483f5adc303bd39c76e11f930ec2340eee57a#2be483f5adc303bd39c76e11f930ec2340eee57a" [[package]] name = "comline-doc-html" version = "0.1.0" -source = "git+https://github.com/ComlineProject/generation?rev=58ff61b4a72a2bcdba6685809e615ffb614e1d8e#58ff61b4a72a2bcdba6685809e615ffb614e1d8e" +source = "git+https://github.com/ComlineProject/generation?rev=9b8336e4acd0a1f10b75aa851c36571f4e1d0d47#9b8336e4acd0a1f10b75aa851c36571f4e1d0d47" dependencies = [ "comline-codegen", "eyre", @@ -643,7 +643,7 @@ dependencies = [ [[package]] name = "comline-doc-markdown" version = "0.1.0" -source = "git+https://github.com/ComlineProject/generation?rev=58ff61b4a72a2bcdba6685809e615ffb614e1d8e#58ff61b4a72a2bcdba6685809e615ffb614e1d8e" +source = "git+https://github.com/ComlineProject/generation?rev=9b8336e4acd0a1f10b75aa851c36571f4e1d0d47#9b8336e4acd0a1f10b75aa851c36571f4e1d0d47" dependencies = [ "comline-codegen", "eyre", diff --git a/Cargo.toml b/Cargo.toml index 566658a..65c57c0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,20 +32,20 @@ eyre = "0.6.8" # needs real I/O (git fetch, filesystem), so it's off by default for # `comline-core`'s wasm32 consumers (the playground editor, the language # server); the CLI is the one consumer that actually runs `comline build`. -comline-core = { git = "https://github.com/ComlineProject/core", rev = "076cae0c3a0639b0c083b61a94f9d4913e853b3f", features = ["deps"] } +comline-core = { git = "https://github.com/ComlineProject/core", rev = "2be483f5adc303bd39c76e11f930ec2340eee57a", features = ["deps"] } # All three pinned to revs that agree on one `comline-codegen`, and bumped # together: comline-rust and comline-typescript's codegen crates consume # `comline-codegen`'s types, so the rev below must be byte-identical to the # one *they* pin - Cargo only unifies a git dependency across identical rev # strings, and two copies of `GenRequest` are two incompatible types. -comline-codegen = { git = "https://github.com/ComlineProject/generation", rev = "58ff61b4a72a2bcdba6685809e615ffb614e1d8e" } +comline-codegen = { git = "https://github.com/ComlineProject/generation", rev = "9b8336e4acd0a1f10b75aa851c36571f4e1d0d47" } # The official Markdown and HTML documentation renderers (`comline doc`), # linked in like the official generators. Same generation rev as # `comline-codegen`. -comline-doc-markdown = { git = "https://github.com/ComlineProject/generation", rev = "58ff61b4a72a2bcdba6685809e615ffb614e1d8e" } -comline-doc-html = { git = "https://github.com/ComlineProject/generation", rev = "58ff61b4a72a2bcdba6685809e615ffb614e1d8e" } -comline-codegen-rust = { git = "https://github.com/ComlineProject/comline-rust", rev = "52e0eadf1c424f9486ee97d75d74cf59bbc1f191", optional = true } -comline-codegen-typescript = { git = "https://github.com/ComlineProject/comline-typescript", rev = "932edaad1fd0a0dba47f8fff132149e03c0340dc", optional = true } +comline-doc-markdown = { git = "https://github.com/ComlineProject/generation", rev = "9b8336e4acd0a1f10b75aa851c36571f4e1d0d47" } +comline-doc-html = { git = "https://github.com/ComlineProject/generation", rev = "9b8336e4acd0a1f10b75aa851c36571f4e1d0d47" } +comline-codegen-rust = { git = "https://github.com/ComlineProject/comline-rust", rev = "89530a72f37180517e1c70f88437b1bedf1e703a", optional = true } +comline-codegen-typescript = { git = "https://github.com/ComlineProject/comline-typescript", rev = "82447d54a8616a1ed37e4a7886df25deb2af7baf", optional = true } # `comline conformance`: the conformance runner (corpus loading, judging, # profile proofs) and its case format, a public spec. Pinned by git rev. comline-runtime-conformance = { git = "https://github.com/ComlineProject/runtime", rev = "4378c91b74ee1ef1debc800a3daf75c874198e70" } diff --git a/src/changes.rs b/src/changes.rs index 71888b2..b9286f3 100644 --- a/src/changes.rs +++ b/src/changes.rs @@ -1,5 +1,7 @@ //! Rendering for `comline_core`'s [`SchemaChanges`], shared by `build` and `diff`. +use comline_core::package::build::VersionBump; +use comline_core::package::config::ir::diff::{ConfigChange, ConfigChanges}; use comline_core::schema::ir::diff::{BreakingChange, Modification, NewFeature, SchemaChanges}; use comline_core::schema::ir::unverified; @@ -37,6 +39,64 @@ pub fn render(changes: &SchemaChanges) { } } +/// Print the config changes that move the version, if any. +pub fn render_config(changes: &ConfigChanges) { + if changes.is_empty() { + return; + } + ui::group(heading("⚙️", "Config changes", changes.0.len())); + for change in &changes.0 { + ui::detail(config_line(change)); + } +} + +fn config_line(change: &ConfigChange) -> String { + let arrow = ui::arrow(); + match change { + ConfigChange::SpecificationVersionChanged { old, new } => mark( + "🔄", + "~", + format!("Changed `specification_version`: {old} {arrow} {new}"), + ), + ConfigChange::DependencyRemoved { project } => { + mark("❌", "-", format!("Removed dependency `{project}`")) + } + ConfigChange::DependencyVersionChanged { project, old, new } => mark( + "🔄", + "~", + format!("Changed dependency `{project}`: {old} {arrow} {new}"), + ), + ConfigChange::DependencyAdded { project, version } => { + mark("➕", "+", format!("Added dependency `{project}` {version}")) + } + ConfigChange::WireFormatChanged { old, new } => mark( + "🔄", + "~", + format!("Changed `wire.format`: {old} {arrow} {new}"), + ), + ConfigChange::WireFramingChanged { old, new } => mark( + "🔄", + "~", + format!("Changed `wire.framing`: {old} {arrow} {new}"), + ), + } +} + +/// The bump a set of changes calls for, in words. +pub fn bump_line(bump: VersionBump) -> String { + let text = match bump { + VersionBump::Major => "major version bump (breaking changes)", + VersionBump::Minor => "minor version bump (new features)", + VersionBump::Patch => "patch version bump (modifications)", + VersionBump::None => "no version bump", + }; + if ui::plain() { + text.to_string() + } else { + format!("⬆️ {text}") + } +} + fn heading(emoji: &str, text: &str, n: usize) -> String { if ui::plain() { format!("{text} ({n}):") @@ -95,6 +155,42 @@ fn breaking_line(change: &BreakingChange) -> String { "!", format!("Added required field `{type_name}.{field_name}`: {field_type}"), ), + BreakingChange::AddedOptionalField { + type_name, + field_name, + field_type, + } => mark( + "⚠️", + "!", + format!( + "Added optional field `{type_name}.{field_name}`: {field_type} (the format can't skip it)" + ), + ), + BreakingChange::ReorderedFields { type_name } => mark( + "🔄", + "~", + format!("Moved fields of `{type_name}` (the format keys them by position)"), + ), + BreakingChange::ReorderedEnumVariants { enum_name } => mark( + "🔄", + "~", + format!("Moved variants of `{enum_name}` (the format encodes them by index)"), + ), + BreakingChange::ReorderedFunctions { protocol_name } => mark( + "🔄", + "~", + format!("Moved functions of `{protocol_name}` (the framing calls them by index)"), + ), + BreakingChange::RenamedProtocol { old_name, new_name } => mark( + "🔄", + "~", + format!("Renamed protocol `{old_name}` {} `{new_name}`", ui::arrow()), + ), + BreakingChange::RenamedNamespace { old_name, new_name } => mark( + "🔄", + "~", + format!("Renamed namespace `{old_name}` {} `{new_name}`", ui::arrow()), + ), BreakingChange::RemovedEnumVariant { enum_name, variant } => { mark("❌", "-", format!("Removed `{enum_name}::{variant}`")) } @@ -349,6 +445,30 @@ fn modification_line(modification: &Modification) -> String { "~", format!("Changed the default of `{type_name}.{field_name}`"), ), + Modification::TypeRespelled { + target, + old_type, + new_type, + } => mark( + "📝", + "~", + format!( + "Respelled the type of `{target}`: {old_type} {} {new_type} (same type)", + ui::arrow() + ), + ), + Modification::ChangedConstantValue { + name, + old_value, + new_value, + } => mark( + "🔧", + "~", + format!( + "Changed constant `{name}`'s value (used only by defaults): {}", + value_change(old_value, new_value) + ), + ), Modification::ChangedErrorMessage { name } => { mark("📝", "~", format!("Changed error `{name}`'s message")) } diff --git a/src/commands/build.rs b/src/commands/build.rs index 8eae910..c42cfcf 100644 --- a/src/commands/build.rs +++ b/src/commands/build.rs @@ -61,7 +61,8 @@ fn build_once(work_dir: &Path) -> Result<()> { .as_ref() .map(|c| !c.is_empty()) .unwrap_or(false) - || !result.dependency_changes.is_empty(); + || !result.dependency_changes.is_empty() + || !result.config_changes.is_empty(); if !has_changes { ui::detail(pkg(format!( @@ -82,7 +83,8 @@ fn build_once(work_dir: &Path) -> Result<()> { ui::group(format!("In dependency `{}`:", dependency.name)); changes::render(&dependency.changes); } - ui::detail(bump_line(result.version_bump)); + changes::render_config(&result.config_changes); + ui::detail(changes::bump_line(result.version_bump)); next_release_line(&result); Ok(()) @@ -121,17 +123,3 @@ fn pkg(body: String) -> String { format!("📦 {body}") } } - -fn bump_line(bump: VersionBump) -> String { - let text = match bump { - VersionBump::Major => "major version bump (breaking changes)", - VersionBump::Minor => "minor version bump (new features)", - VersionBump::Patch => "patch version bump (modifications)", - VersionBump::None => "no version bump", - }; - if ui::plain() { - text.to_string() - } else { - format!("⬆️ {text}") - } -} diff --git a/src/commands/diff.rs b/src/commands/diff.rs index eed1223..c583a0a 100644 --- a/src/commands/diff.rs +++ b/src/commands/diff.rs @@ -1,10 +1,13 @@ -//! `comline diff ` — schema changelog between two frozen versions. +//! `comline diff ` — changelog between two frozen versions: the +//! package's own schema changes, those within its reach of each dependency, +//! its config changes, and the bump they call for (core's comparison, the +//! same one `build` uses). use std::path::Path; -use comline_core::package::build::cas::objects::Commit; +use comline_core::package::build::cas::build::compare; +use comline_core::package::build::cas::objects::{Commit, Tree}; use comline_core::package::build::cas::ObjectStore; -use comline_core::schema::ir::diff::analyze_package_changes; use miette::Result; use crate::commands::ensure_project; @@ -31,9 +34,21 @@ pub fn run(work_dir: &Path, old: &str, new: &str) -> Result<()> { return Ok(()); } - let old_schemas = history::load_schemas(&store, old_commit)?; - let new_schemas = history::load_schemas(&store, new_commit)?; - changes::render(&analyze_package_changes(&old_schemas, &new_schemas)); + let tree = |commit: &Commit| -> Result { + let bytes = store + .read(&commit.tree) + .map_err(|e| miette::miette!("failed to read root tree: {e:#}"))?; + Tree::from_bytes(&bytes).map_err(|e| miette::miette!("corrupt root tree: {e:#}")) + }; + let comparison = compare(&store, &tree(old_commit)?, &tree(new_commit)?) + .map_err(|e| miette::miette!("failed to compare the versions: {e:#}"))?; + changes::render(&comparison.schema_changes); + for dependency in &comparison.dependency_changes { + ui::group(format!("In dependency `{}`:", dependency.name)); + changes::render(&dependency.changes); + } + changes::render_config(&comparison.config_changes); + ui::detail(changes::bump_line(comparison.bump)); Ok(()) } diff --git a/tests/fixtures/generators/Cargo.lock b/tests/fixtures/generators/Cargo.lock index d0c624f..bca0cc8 100644 --- a/tests/fixtures/generators/Cargo.lock +++ b/tests/fixtures/generators/Cargo.lock @@ -79,7 +79,7 @@ dependencies = [ [[package]] name = "comline-codegen" version = "0.1.0" -source = "git+https://github.com/ComlineProject/generation?rev=58ff61b4a72a2bcdba6685809e615ffb614e1d8e#58ff61b4a72a2bcdba6685809e615ffb614e1d8e" +source = "git+https://github.com/ComlineProject/generation?rev=9b8336e4acd0a1f10b75aa851c36571f4e1d0d47#9b8336e4acd0a1f10b75aa851c36571f4e1d0d47" dependencies = [ "comline-core", "eyre", @@ -93,7 +93,7 @@ dependencies = [ [[package]] name = "comline-codegen-rust" version = "0.1.0" -source = "git+https://github.com/ComlineProject/comline-rust?rev=52e0eadf1c424f9486ee97d75d74cf59bbc1f191#52e0eadf1c424f9486ee97d75d74cf59bbc1f191" +source = "git+https://github.com/ComlineProject/comline-rust?rev=89530a72f37180517e1c70f88437b1bedf1e703a#89530a72f37180517e1c70f88437b1bedf1e703a" dependencies = [ "comline-codegen", "comline-core", @@ -103,7 +103,7 @@ dependencies = [ [[package]] name = "comline-core" version = "0.1.0" -source = "git+https://github.com/ComlineProject/core?rev=076cae0c3a0639b0c083b61a94f9d4913e853b3f#076cae0c3a0639b0c083b61a94f9d4913e853b3f" +source = "git+https://github.com/ComlineProject/core?rev=2be483f5adc303bd39c76e11f930ec2340eee57a#2be483f5adc303bd39c76e11f930ec2340eee57a" dependencies = [ "blake3", "ciborium", @@ -120,12 +120,12 @@ dependencies = [ [[package]] name = "comline-core-stdlib" version = "0.1.0" -source = "git+https://github.com/ComlineProject/core?rev=076cae0c3a0639b0c083b61a94f9d4913e853b3f#076cae0c3a0639b0c083b61a94f9d4913e853b3f" +source = "git+https://github.com/ComlineProject/core?rev=2be483f5adc303bd39c76e11f930ec2340eee57a#2be483f5adc303bd39c76e11f930ec2340eee57a" [[package]] name = "comline-doc-html" version = "0.1.0" -source = "git+https://github.com/ComlineProject/generation?rev=58ff61b4a72a2bcdba6685809e615ffb614e1d8e#58ff61b4a72a2bcdba6685809e615ffb614e1d8e" +source = "git+https://github.com/ComlineProject/generation?rev=9b8336e4acd0a1f10b75aa851c36571f4e1d0d47#9b8336e4acd0a1f10b75aa851c36571f4e1d0d47" dependencies = [ "comline-codegen", "eyre", @@ -136,7 +136,7 @@ dependencies = [ [[package]] name = "comline-doc-markdown" version = "0.1.0" -source = "git+https://github.com/ComlineProject/generation?rev=58ff61b4a72a2bcdba6685809e615ffb614e1d8e#58ff61b4a72a2bcdba6685809e615ffb614e1d8e" +source = "git+https://github.com/ComlineProject/generation?rev=9b8336e4acd0a1f10b75aa851c36571f4e1d0d47#9b8336e4acd0a1f10b75aa851c36571f4e1d0d47" dependencies = [ "comline-codegen", "eyre", diff --git a/tests/fixtures/generators/Cargo.toml b/tests/fixtures/generators/Cargo.toml index 2ab33d8..8d8442a 100644 --- a/tests/fixtures/generators/Cargo.toml +++ b/tests/fixtures/generators/Cargo.toml @@ -12,7 +12,7 @@ publish = false [dependencies] # The same revs the CLI pins, so the real generator's output is comparable # byte for byte with the CLI's built-in one. -comline-codegen = { git = "https://github.com/ComlineProject/generation", rev = "58ff61b4a72a2bcdba6685809e615ffb614e1d8e" } -comline-doc-markdown = { git = "https://github.com/ComlineProject/generation", rev = "58ff61b4a72a2bcdba6685809e615ffb614e1d8e" } -comline-doc-html = { git = "https://github.com/ComlineProject/generation", rev = "58ff61b4a72a2bcdba6685809e615ffb614e1d8e" } -comline-codegen-rust = { git = "https://github.com/ComlineProject/comline-rust", rev = "52e0eadf1c424f9486ee97d75d74cf59bbc1f191" } +comline-codegen = { git = "https://github.com/ComlineProject/generation", rev = "9b8336e4acd0a1f10b75aa851c36571f4e1d0d47" } +comline-doc-markdown = { git = "https://github.com/ComlineProject/generation", rev = "9b8336e4acd0a1f10b75aa851c36571f4e1d0d47" } +comline-doc-html = { git = "https://github.com/ComlineProject/generation", rev = "9b8336e4acd0a1f10b75aa851c36571f4e1d0d47" } +comline-codegen-rust = { git = "https://github.com/ComlineProject/comline-rust", rev = "89530a72f37180517e1c70f88437b1bedf1e703a" }