Skip to main content

multiversx_sc_meta/cmd/template/
repo_version.rs

1use crate::{version::FrameworkVersion, version_history::LAST_TEMPLATE_VERSION};
2
3pub enum RepoVersion {
4    Master,
5    Tag(String),
6}
7
8impl RepoVersion {
9    pub fn url(&self) -> String {
10        match self {
11            RepoVersion::Master => {
12                "https://github.com/multiversx/mx-sdk-rs/archive/refs/heads/master.zip".to_string()
13            }
14            RepoVersion::Tag(tag) => {
15                format!("https://github.com/multiversx/mx-sdk-rs/archive/refs/tags/v{tag}.zip")
16            }
17        }
18    }
19
20    pub fn temp_dir_name(&self) -> String {
21        match self {
22            RepoVersion::Master => "mx-sdk-rs-master".to_string(),
23            RepoVersion::Tag(tag) => {
24                format!("mx-sdk-rs-{tag}")
25            }
26        }
27    }
28
29    pub fn get_tag(&self) -> FrameworkVersion {
30        match self {
31            RepoVersion::Master => LAST_TEMPLATE_VERSION,
32            RepoVersion::Tag(tag) => FrameworkVersion::from_string_template(tag),
33        }
34    }
35}