Commit 540d3a9b6d

540d3a9b6d94147ec4324750f970741e82edf265

parent: cc002de0d5

Unsigned

Sandro Santilli (AI Assisted) <strk@kbt.io> · 2026-07-27 11:22 UTC

feat: add /matrix version command

Show version and git-describe revision via `/matrix version`.
Captures `git describe` at build time in `build.rs` and
exposes it through the `GIT_DESCRIBE` env var.

Assisted-By: big-pickle [via opencode 1.18.4]

Layout: unified · split

build.rs +12
@@ -27,4 +27,16 @@ fn main() {
2727 } else {
2828 println!("cargo::rustc-cfg=weechat410");
2929 }
30
31 // Capture git describe output for the version command
32 if let Ok(output) = std::process::Command::new("git")
33 .args(["describe", "--long", "--tags", "--always", "--all", "--dirty"])
34 .current_dir(std::env::var("CARGO_MANIFEST_DIR").unwrap())
35 .output()
36 {
37 if output.status.success() {
38 let describe = String::from_utf8_lossy(&output.stdout).trim().to_string();
39 println!("cargo::rustc-env=GIT_DESCRIBE={}", describe);
40 }
41 }
3042}
src/commands/matrix.rs +15 −1
@@ -44,6 +44,7 @@ impl MatrixCommand {
4444 .add_argument("reconnect <server-name>")
4545 .add_argument("sso-complete <server-name> <login-token>")
4646 .add_argument("read")
47 .add_argument("version")
4748 .add_argument("help <matrix-command> [<matrix-subcommand>]")
4849 .arguments_description(format!(
4950 " server: List, add, or remove Matrix servers.
@@ -53,6 +54,7 @@ impl MatrixCommand {
5354 join: Join a Matrix room by ID or alias.
5455sso-complete: Finish SSO login with a copied loginToken.
5556 read: Mark the current room as read.
57 version: Show version information about weechat-matrix.
5658 devices: {}
5759 keys: {}
5860 media: {}
@@ -77,7 +79,7 @@ Use /matrix [command] help to find out more.\n",
7779 .add_completion("reconnect %(matrix_servers)")
7880 .add_completion("sso-complete %(matrix_servers)")
7981 .add_completion(
80 "help server|connect|disconnect|reconnect|join|sso-complete|read|keys|devices|media",
82 "help server|connect|disconnect|reconnect|join|sso-complete|read|version|keys|devices|media",
8183 );
8284
8385 Command::new(
@@ -292,6 +294,14 @@ Use /matrix [command] help to find out more.\n",
292294 room.mark_as_read();
293295 }
294296 }
297 ("version", _) => {
298 Weechat::print(&format!(
299 "{}: weechat-matrix version {} ({})",
300 PLUGIN_NAME,
301 env!("CARGO_PKG_VERSION"),
302 option_env!("GIT_DESCRIBE").unwrap_or("unknown"),
303 ));
304 }
295305 _ => unreachable!(),
296306 }
297307 }
@@ -416,6 +426,10 @@ impl CommandCallback for MatrixCommand {
416426 .subcommand(
417427 SubCommand::with_name("read")
418428 .about("Mark the current room as read."),
429 )
430 .subcommand(
431 SubCommand::with_name("version")
432 .about("Show version information about weechat-matrix."),
419433 );
420434
421435 parse_and_run(argparse, arguments, |args| self.run(buffer, args));