Radish alpha
r
rad:z4D5UCArafTzTQpDZNQRuqswh3ury
Radicle desktop app
Radicle
Git
Add short commit hash in about popup for macOS build
Sebastian Martinez committed 0 years ago
commit 865497ce387bec55dc70e835f90c84005e1649e4
parent f0ef087
5 files changed +61 -2
modified crates/radicle-tauri/build.rs
@@ -1,3 +1,12 @@
+
use std::process::Command;
+

fn main() {
+
    let output = Command::new("git")
+
        .args(&["rev-parse", "--short", "HEAD"])
+
        .output()
+
        .expect("failed to execute git");
+
    let git_head = String::from_utf8(output.stdout).unwrap();
+
    println!("cargo:rustc-env=GIT_HEAD={}", git_head);
+

    tauri_build::build()
}
modified crates/radicle-tauri/src/commands/startup.rs
@@ -1,16 +1,47 @@
use std::collections::BTreeMap;

+
use serde::Serialize;
+
use tauri::{AppHandle, Emitter, Manager};
+

use radicle::cob::cache::COBS_DB_FILE;
use radicle::identity::RepoId;
use radicle::node::{Handle, Node, NOTIFICATIONS_DB_FILE};
use radicle::storage::ReadStorage;
-
use tauri::{AppHandle, Emitter, Manager};

use radicle_types::config::Config;
use radicle_types::error::Error;
use radicle_types::traits::Profile;
use radicle_types::{domain, AppState};

+
pub struct Version {
+
    pub version: String,
+
    pub head: String,
+
}
+

+
impl Serialize for Version {
+
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+
    where
+
        S: serde::Serializer,
+
    {
+
        serializer.serialize_str(&format!("{} ({})", self.version, self.head))
+
    }
+
}
+

+
#[tauri::command]
+
pub(crate) fn version(app: AppHandle) -> Result<Version, Error> {
+
    let version = app
+
        .config()
+
        .version
+
        .clone()
+
        .expect("The build version has not been set.");
+
    pub const GIT_HEAD: &str = env!("GIT_HEAD");
+

+
    Ok(Version {
+
        version,
+
        head: GIT_HEAD.to_string(),
+
    })
+
}
+

#[tauri::command]
pub(crate) fn startup(app: AppHandle) -> Result<Config, Error> {
    let profile = radicle::Profile::load()?;
modified crates/radicle-tauri/src/lib.rs
@@ -57,6 +57,7 @@ pub fn run() {
            repo::repo_by_id,
            repo::repo_count,
            startup::startup,
+
            startup::version,
            thread::create_issue_comment,
            thread::create_patch_comment,
        ])
modified crates/radicle-tauri/tauri.conf.json
@@ -1,8 +1,8 @@
{
  "productName": "Radicle",
  "mainBinaryName": "radicle-desktop",
-
  "version": "0.2.0",
  "identifier": "xyz.radicle.desktop",
+
  "version": "0.2.0",
  "build": {
    "beforeDevCommand": "npm start",
    "devUrl": "http://localhost:1420",
modified src/components/Settings.svelte
@@ -1,8 +1,12 @@
<script lang="ts">
  import type { ComponentProps } from "svelte";

+
  import { onMount } from "svelte";
+
  import { invoke } from "@app/lib/invoke";
+

  import AnnounceSwitch from "./AnnounceSwitch.svelte";
  import Border from "./Border.svelte";
+
  import CopyableId from "./CopyableId.svelte";
  import FontSizeSwitch from "./FontSizeSwitch.svelte";
  import Icon from "./Icon.svelte";
  import NakedButton from "./NakedButton.svelte";
@@ -15,6 +19,12 @@
    popoverProps: Partial<ComponentProps<typeof Popover>>;
  }

+
  let version = $state("");
+

+
  onMount(async () => {
+
    version = await invoke<string>("version");
+
  });
+

  const {
    compact = true,
    styleHeight = "2.5rem",
@@ -42,6 +52,14 @@
        <div
          class="global-flex"
          style:justify-content="space-between"
+
          style:width="100%"
+
          style:min-height="2rem">
+
          Version <CopyableId id={version} />
+
        </div>
+

+
        <div
+
          class="global-flex"
+
          style:justify-content="space-between"
          style:width="100%">
          Theme <ThemeSwitch />
        </div>