Skip to content

Commit c5828d4

Browse files
committed
Add VersionInfo to ProjectMetadata
1 parent cae2a1e commit c5828d4

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

scarb/src/metadata/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use crate::core::manifest::{
1616
};
1717
use crate::core::{ManifestDependency, Package, PackageId, SourceId, Workspace};
1818
use crate::ops::resolve_workspace;
19+
use crate::version::VersionInfo;
1920

2021
mod metadata_version;
2122

@@ -34,6 +35,7 @@ pub enum Metadata {
3435
pub struct ProjectMetadata {
3536
pub version: MetadataVersionPin<1>,
3637
pub app_exe: Option<PathBuf>,
38+
pub app_version_info: VersionInfo,
3739
pub target_dir: Option<Utf8PathBuf>,
3840
pub workspace: WorkspaceMetadata,
3941
pub packages: Vec<PackageMetadata>,
@@ -108,6 +110,7 @@ impl ProjectMetadata {
108110
Ok(Self {
109111
version: MetadataVersionPin::<1>,
110112
app_exe: ws.config().app_exe().ok().map(Into::into),
113+
app_version_info: crate::version::get(),
111114
target_dir: Some(ws.target_dir().path_unchecked().to_path_buf()),
112115
workspace: WorkspaceMetadata::new(ws)?,
113116
packages,

scarb/src/version.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,25 @@
22
33
use std::fmt;
44

5+
use serde::{Deserialize, Serialize};
6+
57
/// Scarb's version.
8+
#[derive(Serialize, Deserialize, Debug)]
69
pub struct VersionInfo {
710
pub version: String,
811
pub commit_info: Option<CommitInfo>,
912
pub cairo: CairoVersionInfo,
1013
}
1114

1215
/// Cairo's version.
16+
#[derive(Serialize, Deserialize, Debug)]
1317
pub struct CairoVersionInfo {
1418
pub version: String,
1519
pub commit_info: Option<CommitInfo>,
1620
}
1721

1822
/// Information about the Git repository where the crate was built from.
23+
#[derive(Serialize, Deserialize, Debug)]
1924
pub struct CommitInfo {
2025
pub short_commit_hash: String,
2126
pub commit_hash: String,

scarb/tests/e2e/metadata.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,22 @@ fn simple() {
5353
r#"{
5454
"version": 1,
5555
"app_exe": "[..]",
56+
"app_version_info": {
57+
"version": "[..]",
58+
"commit_info": {
59+
"short_commit_hash": "[..]",
60+
"commit_hash": "[..]",
61+
"commit_date": "[..]"
62+
},
63+
"cairo": {
64+
"version": "[..]",
65+
"commit_info": {
66+
"short_commit_hash": "[..]",
67+
"commit_hash": "[..]",
68+
"commit_date": [..]
69+
}
70+
}
71+
},
5672
"target_dir": "[..]/target",
5773
"workspace": {
5874
"root": "[..]",

0 commit comments

Comments
 (0)