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
14 changes: 7 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
120 changes: 120 additions & 0 deletions src/changes.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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}):")
Expand Down Expand Up @@ -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}`"))
}
Expand Down Expand Up @@ -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"))
}
Expand Down
20 changes: 4 additions & 16 deletions src/commands/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand All @@ -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(())
Expand Down Expand Up @@ -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}")
}
}
27 changes: 21 additions & 6 deletions src/commands/diff.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
//! `comline diff <old> <new>` — schema changelog between two frozen versions.
//! `comline diff <old> <new>` — 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;
Expand All @@ -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<Tree> {
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(())
}

Expand Down
12 changes: 6 additions & 6 deletions tests/fixtures/generators/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions tests/fixtures/generators/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Loading