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
10 changes: 5 additions & 5 deletions 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ toml = "0.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 = "bd9d9f4557e56db1dbcece1b6fae54c1fc5394fd", features = ["deps"] }
comline-core = { git = "https://github.com/ComlineProject/core", rev = "af0371f84994da906805cc8c9b6693236adb86f5", 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 = "46ff2b0f98af9c3b6cf92a15f4cf311ef4c19d64" }
comline-codegen-rust = { git = "https://github.com/ComlineProject/comline-rust", rev = "7a2c04c871be6ee13ed7e9a64f45b72babda7790", optional = true }
comline-codegen-typescript = { git = "https://github.com/ComlineProject/comline-typescript", rev = "0309d82a8871fc459143ddde653fc8f395571588", optional = true }
comline-codegen = { git = "https://github.com/ComlineProject/generation", rev = "64136010b9e9ae7ccc2f6c1d8400bccb5da42e5e" }
comline-codegen-rust = { git = "https://github.com/ComlineProject/comline-rust", rev = "edef1c870f99eae43c4444f7b3875a5145ee35a0", optional = true }
comline-codegen-typescript = { git = "https://github.com/ComlineProject/comline-typescript", rev = "d30ae2919180262ee4495faa83cd3f61b971b81c", optional = true }

[features]
# Which language generators are compiled in. Drop one to shed its whole
Expand Down
48 changes: 48 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ pub struct Cli {
pub command: Commands,
}

/// How far `comline release --raise` goes.
#[derive(Debug, Clone, Copy, clap::ValueEnum)]
pub enum ReleaseLevel {
Patch,
Minor,
Major,
}

#[derive(Subcommand, Debug)]
pub enum Commands {
/// Compile the project and freeze a new immutable version
Expand Down Expand Up @@ -170,6 +178,46 @@ history.")]
dry_run: bool,
},

/// Release the builds since the last release as a version
#[command(long_about = "\
Builds record history under pre-release versions (`0.3.0-dev.2`: the release \
they lead to, and a count). A release is the version consumers see. This builds \
first, so what's released is what's in `src/` now, then creates the version from \
the highest bump the changes since the last release call for: a breaking change \
is a major (before 1.0, the minor), a new feature a minor, anything else a patch. \
The first release is 0.1.0.

`--raise` releases a higher bump than the changes show (a behaviour change the \
schema can't express), with a `--reason` recorded with the release. It never \
lowers the bump.

`comline release 1.0` makes a 0.x package stable: it says what 1.0 commits to \
and what the package exposes, then releases 1.0.0.

Raising to major and releasing 1.0 ask for confirmation on a terminal; \
otherwise pass `--yes`.

Examples:
comline release
comline release --raise minor --reason \"`ping` now retries on timeout\"
comline release 1.0")]
Release {
/// `1.0`, to make a 0.x package stable; otherwise omitted
version: Option<String>,

/// Release a higher bump than the changes call for
#[arg(long, value_enum, value_name = "LEVEL")]
raise: Option<ReleaseLevel>,

/// Why: required with `--raise`, recorded with the release
#[arg(long, value_name = "TEXT")]
reason: Option<String>,

/// Don't ask for confirmation
#[arg(long, short)]
yes: bool,
},

/// Discard the version history (delete `.comline/`)
#[command(long_about = "\
Delete the project's `.comline/` content-addressable store — every frozen \
Expand Down
30 changes: 29 additions & 1 deletion src/commands/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ fn build_once(work_dir: &Path, release: bool) -> Result<()> {
ui::success("Project built");

if result.is_initial_build() {
ui::detail(pkg(format!("initial version {}", result.current_version)));
ui::detail(pkg(format!("initial build {}", result.current_version)));
next_release_line(&result);
return Ok(());
}

Expand All @@ -54,6 +55,7 @@ fn build_once(work_dir: &Path, release: bool) -> Result<()> {
"version {} (no changes)",
result.current_version
)));
next_release_line(&result);
return Ok(());
}

Expand All @@ -68,10 +70,36 @@ fn build_once(work_dir: &Path, release: bool) -> Result<()> {
changes::render(&dependency.changes);
}
ui::detail(bump_line(result.version_bump));
next_release_line(&result);

Ok(())
}

/// What `comline release` would make now: the release this build leads to.
/// Nothing when the latest commit is itself a release.
fn next_release_line(result: &build::BuildResult) {
// A build's version is the release it leads to plus `-dev.N`.
let Some((next, _)) = result.current_version.split_once('-') else {
return;
};
let since = match &result.last_release {
Some(last) => format!(" ({} since {last})", bump_word(result.release_bump)),
None => " (the first release)".to_string(),
};
ui::detail(format!(
"next release: {next}{since} — run `comline release`"
));
}

fn bump_word(bump: VersionBump) -> &'static str {
match bump {
VersionBump::Major => "breaking changes",
VersionBump::Minor => "new features",
VersionBump::Patch => "modifications",
VersionBump::None => "nothing that calls for a bump",
}
}

/// A `📦`-prefixed package line, or plain text (with an ASCII arrow) under `--plain`.
fn pkg(body: String) -> String {
if ui::plain() {
Expand Down
11 changes: 10 additions & 1 deletion src/commands/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,18 @@ fn expand_versions(
}])
}
VersionSpec::All => {
// Every release: what consumers see. The builds between them
// are named one by one when wanted.
let chain = history::load(work_dir)?;
let store = ObjectStore::new(work_dir);
chain
let releases: Vec<_> = chain.iter().filter(|e| e.commit.is_release()).collect();
if releases.is_empty() {
return Err(miette!(
"`package_versions = \"all\"` generates every release, and there's none yet; \
run `comline release`, or name the builds to generate"
));
}
releases
.iter()
.map(|e| gen_version_from_commit(&store, &e.commit.version, &e.commit))
.collect()
Expand Down
1 change: 1 addition & 0 deletions src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub mod completions;
pub mod diff;
pub mod generate;
pub mod new;
pub mod release;
pub mod reset;
pub mod targets;

Expand Down
Loading
Loading