Release bridge milestone 0.2.0
This commit is contained in:
parent
387ea86088
commit
fa486c61ae
|
|
@ -931,7 +931,7 @@ checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65"
|
|||
|
||||
[[package]]
|
||||
name = "vsg_bridge_ls"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "vsg_bridge_ls"
|
||||
description = "A very featureless VSG to lsp bridge"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
edition = "2021"
|
||||
rust-version = "1.85.1"
|
||||
categories =["developement-tools"]
|
||||
|
|
|
|||
|
|
@ -50,9 +50,12 @@ Activate the environment and verify both executables:
|
|||
. .venv/bin/activate
|
||||
command -v vsg
|
||||
command -v vsg_bridge_ls
|
||||
vsg_bridge_ls --help
|
||||
vsg_bridge_ls --version
|
||||
```
|
||||
|
||||
The version includes both the Cargo release and build commit, for example
|
||||
`0.2.0+git.0123abcd`, so editor logs can identify the exact binary.
|
||||
|
||||
## 3. Configure Helix
|
||||
|
||||
Add this minimal setup to `~/.config/helix/languages.toml`:
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
use std::fs;
|
||||
use std::process::Command;
|
||||
|
||||
fn main() {
|
||||
println!("cargo:rerun-if-changed=.git/HEAD");
|
||||
if let Ok(head) = fs::read_to_string(".git/HEAD") {
|
||||
if let Some(reference) = head.trim().strip_prefix("ref: ") {
|
||||
println!("cargo:rerun-if-changed=.git/{reference}");
|
||||
}
|
||||
}
|
||||
|
||||
let revision = if std::path::Path::new(".git").exists() {
|
||||
Command::new("git")
|
||||
.args(["rev-parse", "--short=8", "HEAD"])
|
||||
.output()
|
||||
.ok()
|
||||
.filter(|output| output.status.success())
|
||||
.and_then(|output| String::from_utf8(output.stdout).ok())
|
||||
.map(|revision| revision.trim().to_owned())
|
||||
.filter(|revision| {
|
||||
!revision.is_empty() && revision.bytes().all(|byte| byte.is_ascii_hexdigit())
|
||||
})
|
||||
.unwrap_or_else(|| "unknown".to_owned())
|
||||
} else {
|
||||
"unknown".to_owned()
|
||||
};
|
||||
|
||||
println!("cargo:rustc-env=VSG_BRIDGE_GIT_SHA={revision}");
|
||||
}
|
||||
24
src/lib.rs
24
src/lib.rs
|
|
@ -19,9 +19,16 @@ use tower_lsp::{LspService, Server};
|
|||
pub use runner::{ProcessVsgRunner, VsgRunner};
|
||||
pub use server::Backend;
|
||||
|
||||
/// Package version paired with the source revision used for this build.
|
||||
pub const VERSION: &str = concat!(
|
||||
env!("CARGO_PKG_VERSION"),
|
||||
"+git.",
|
||||
env!("VSG_BRIDGE_GIT_SHA")
|
||||
);
|
||||
|
||||
/// Command-line configuration for the language server.
|
||||
#[derive(Clone, Debug, Parser, PartialEq, Eq)]
|
||||
#[command(version, about, long_about = None)]
|
||||
#[command(version = VERSION, about, long_about = None)]
|
||||
pub struct Options {
|
||||
/// VSG configuration files, in the order in which VSG should load them.
|
||||
#[arg(short, long)]
|
||||
|
|
@ -71,10 +78,10 @@ where
|
|||
mod tests {
|
||||
//! Unit tests for command-line option translation.
|
||||
|
||||
use super::{run, Options};
|
||||
use super::{run, Options, VERSION};
|
||||
use crate::VsgRunner;
|
||||
use anyhow::Result;
|
||||
use clap::Parser;
|
||||
use clap::{CommandFactory, Parser};
|
||||
use std::sync::Arc;
|
||||
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
||||
|
||||
|
|
@ -145,6 +152,17 @@ mod tests {
|
|||
assert!(!options.experimental_multi_rule_line_fix);
|
||||
}
|
||||
|
||||
/// CLI version output identifies both the release and source revision.
|
||||
#[test]
|
||||
fn version_includes_source_revision() {
|
||||
assert_eq!(Options::command().get_version(), Some(VERSION));
|
||||
assert!(VERSION.starts_with("0.2.0+git."));
|
||||
assert!(VERSION
|
||||
.strip_prefix("0.2.0+git.")
|
||||
.is_some_and(|revision| revision == "unknown"
|
||||
|| (revision.len() == 8 && revision.bytes().all(|byte| byte.is_ascii_hexdigit()))));
|
||||
}
|
||||
|
||||
/// The multi-rule line action requires an explicit runtime opt-in.
|
||||
#[test]
|
||||
fn parses_experimental_multi_rule_line_flag() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue