Unnamed repository; edit this file 'description' to name the repository.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//! Code for representing rust-analyzer's release version number.
#![expect(dead_code)]

use std::fmt;

/// Information about the git repository where rust-analyzer was built from.
pub(crate) struct CommitInfo {
    pub(crate) short_commit_hash: &'static str,
    pub(crate) commit_hash: &'static str,
    pub(crate) commit_date: &'static str,
}

/// Cargo's version.
pub(crate) struct VersionInfo {
    /// rust-analyzer's version, such as "1.57.0", "1.58.0-beta.1", "1.59.0-nightly", etc.
    pub(crate) version: &'static str,
    /// The release channel we were built for (stable/beta/nightly/dev).
    ///
    /// `None` if not built via bootstrap.
    pub(crate) release_channel: Option<&'static str>,
    /// Information about the Git repository we may have been built from.
    ///
    /// `None` if not built from a git repo.
    pub(crate) commit_info: Option<CommitInfo>,
}

impl fmt::Display for VersionInfo {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "{}", self.version)?;

        if let Some(ci) = &self.commit_info {
            write!(f, " ({} {})", ci.short_commit_hash, ci.commit_date)?;
        };
        Ok(())
    }
}

/// Returns information about cargo's version.
pub(crate) const fn version() -> VersionInfo {
    let version = match option_env!("CFG_RELEASE") {
        Some(x) => x,
        None => "0.0.0",
    };

    let release_channel = option_env!("CFG_RELEASE_CHANNEL");
    let commit_info = match (
        option_env!("RA_COMMIT_SHORT_HASH"),
        option_env!("RA_COMMIT_HASH"),
        option_env!("RA_COMMIT_DATE"),
    ) {
        (Some(short_commit_hash), Some(commit_hash), Some(commit_date)) => {
            Some(CommitInfo { short_commit_hash, commit_hash, commit_date })
        }
        _ => None,
    };

    VersionInfo { version, release_channel, commit_info }
}
href='#n166'>166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
{
  "nodes": {
    "crane": {
      "flake": false,
      "locked": {
        "lastModified": 1644785799,
        "narHash": "sha256-VpAJO1L0XeBvtCuNGK4IDKp6ENHIpTrlaZT7yfBCvwo=",
        "owner": "ipetkov",
        "repo": "crane",
        "rev": "fc7a94f841347c88f2cb44217b2a3faa93e2a0b2",
        "type": "github"
      },
      "original": {
        "owner": "ipetkov",
        "repo": "crane",
        "type": "github"
      }
    },
    "devshell": {
      "inputs": {
        "flake-utils": "flake-utils",
        "nixpkgs": [
          "nixCargoIntegration",
          "nixpkgs"
        ]
      },
      "locked": {
        "lastModified": 1646667754,
        "narHash": "sha256-LahZHvCC3UVzGQ55iWDRZkuDssXl1rYgqgScrPV9S38=",
        "owner": "numtide",
        "repo": "devshell",
        "rev": "59fbe1dfc0de8c3332957c16998a7d16dff365d8",
        "type": "github"
      },
      "original": {
        "owner": "numtide",
        "repo": "devshell",
        "type": "github"
      }
    },
    "dream2nix": {
      "inputs": {
        "alejandra": [
          "nixCargoIntegration",
          "nixpkgs"
        ],
        "crane": "crane",
        "flake-utils-pre-commit": [
          "nixCargoIntegration",
          "nixpkgs"
        ],
        "gomod2nix": [
          "nixCargoIntegration",
          "nixpkgs"
        ],
        "mach-nix": [
          "nixCargoIntegration",
          "nixpkgs"
        ],
        "nixpkgs": [
          "nixCargoIntegration",
          "nixpkgs"
        ],
        "node2nix": [
          "nixCargoIntegration",
          "nixpkgs"
        ],
        "poetry2nix": [
          "nixCargoIntegration",
          "nixpkgs"
        ],
        "pre-commit-hooks": [
          "nixCargoIntegration",
          "nixpkgs"
        ]
      },
      "locked": {
        "lastModified": 1646710334,
        "narHash": "sha256-eLBcDgcbOUfeH4k6SEW5a5v0PTp2KNCn+5ZXIoWGYww=",
        "owner": "nix-community",
        "repo": "dream2nix",
        "rev": "5dcfbfd3b60ce0208b894c1bdea00e2bdf80ca6a",
        "type": "github"
      },
      "original": {
        "owner": "nix-community",
        "ref": "main",
        "repo": "dream2nix",
        "type": "github"
      }
    },
    "flake-utils": {
      "locked": {
        "lastModified": 1642700792,
        "narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=",
        "owner": "numtide",
        "repo": "flake-utils",
        "rev": "846b2ae0fc4cc943637d3d1def4454213e203cba",
        "type": "github"
      },
      "original": {
        "owner": "numtide",
        "repo": "flake-utils",
        "type": "github"
      }
    },
    "flake-utils_2": {
      "locked": {
        "lastModified": 1637014545,
        "narHash": "sha256-26IZAc5yzlD9FlDT54io1oqG/bBoyka+FJk5guaX4x4=",
        "owner": "numtide",
        "repo": "flake-utils",
        "rev": "bba5dcc8e0b20ab664967ad83d24d64cb64ec4f4",
        "type": "github"
      },
      "original": {
        "owner": "numtide",
        "repo": "flake-utils",
        "type": "github"
      }
    },
    "nixCargoIntegration": {
      "inputs": {
        "devshell": "devshell",
        "dream2nix": "dream2nix",
        "nixpkgs": [
          "nixpkgs"
        ],
        "rustOverlay": [
          "rust-overlay"
        ]
      },
      "locked": {
        "lastModified": 1646766572,
        "narHash": "sha256-DV3+zxvAIKsMHsHedJKYFsracvFyLKpFQqurUBR86oY=",
        "owner": "yusdacra",
        "repo": "nix-cargo-integration",
        "rev": "3a3f47f43ba486b7554164a698c8dfc5a38624ce",
        "type": "github"
      },
      "original": {
        "owner": "yusdacra",
        "repo": "nix-cargo-integration",
        "type": "github"
      }
    },
    "nixpkgs": {
      "locked": {
        "lastModified": 1646497237,
        "narHash": "sha256-Ccpot1h/rV8MgcngDp5OrdmLTMaUTbStZTR5/sI7zW0=",
        "owner": "nixos",
        "repo": "nixpkgs",
        "rev": "062a0c5437b68f950b081bbfc8a699d57a4ee026",
        "type": "github"
      },
      "original": {
        "owner": "nixos",
        "ref": "nixos-unstable",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "root": {
      "inputs": {
        "nixCargoIntegration": "nixCargoIntegration",
        "nixpkgs": "nixpkgs",
        "rust-overlay": "rust-overlay"
      }
    },
    "rust-overlay": {
      "inputs": {
        "flake-utils": "flake-utils_2",
        "nixpkgs": [
          "nixpkgs"
        ]
      },
      "locked": {
        "lastModified": 1646792695,
        "narHash": "sha256-2drCXIKIQnJMlTZbcCfuHZAh+iPcdlRkCqtZnA6MHLY=",
        "owner": "oxalica",
        "repo": "rust-overlay",
        "rev": "7f599870402c8d2a5806086c8ee0f2d92b175c54",
        "type": "github"
      },
      "original": {
        "owner": "oxalica",
        "repo": "rust-overlay",
        "type": "github"
      }
    }
  },
  "root": "root",
  "version": 7
}