Skip to content

Commit

Permalink
Merge c00d0d3 into 097d5cb
Browse files Browse the repository at this point in the history
  • Loading branch information
baoyachi committed Jun 30, 2022
2 parents 097d5cb + c00d0d3 commit d258575
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
1 change: 1 addition & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ jobs:
run: cargo tarpaulin -o Lcov --output-dir ./coverage
- name: Coveralls
if: matrix.rust == 'stable'
continue-on-error: true
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
4 changes: 2 additions & 2 deletions src/build.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::collections::HashMap;
use std::collections::BTreeMap;

pub type ShadowConst = &'static str;

pub trait ShadowGen {
fn gen_const(&self) -> HashMap<ShadowConst, ConstVal>;
fn gen_const(&self) -> BTreeMap<ShadowConst, ConstVal>;
}

#[derive(Debug, Clone)]
Expand Down
12 changes: 6 additions & 6 deletions src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ use crate::env::dep_source_replace::filter_cargo_tree;
use crate::time::now_data_time;
use crate::Format;
use is_debug::build_channel;
use std::collections::HashMap;
use std::collections::BTreeMap;

#[derive(Default, Debug)]
pub struct SystemEnv {
map: HashMap<ShadowConst, ConstVal>,
map: BTreeMap<ShadowConst, ConstVal>,
}

const BUILD_OS: ShadowConst = "BUILD_OS";
Expand All @@ -35,7 +35,7 @@ const PKG_VERSION_PATCH: ShadowConst = "PKG_VERSION_PATCH";
const PKG_VERSION_PRE: ShadowConst = "PKG_VERSION_PRE";

impl SystemEnv {
fn init(&mut self, std_env: &HashMap<String, String>) -> SdResult<()> {
fn init(&mut self, std_env: &BTreeMap<String, String>) -> SdResult<()> {
let mut update_val = |c: ShadowConst, v: String| {
if let Some(mut val) = self.map.get_mut(c) {
val.t = ConstType::Str;
Expand Down Expand Up @@ -195,7 +195,7 @@ mod dep_source_replace {
}
}

pub fn new_system_env(std_env: &HashMap<String, String>) -> HashMap<ShadowConst, ConstVal> {
pub fn new_system_env(std_env: &BTreeMap<String, String>) -> BTreeMap<ShadowConst, ConstVal> {
let mut env = SystemEnv::default();
env.map.insert(
BUILD_OS,
Expand Down Expand Up @@ -274,7 +274,7 @@ pub fn new_system_env(std_env: &HashMap<String, String>) -> HashMap<ShadowConst,

#[derive(Default, Debug)]
pub struct Project {
map: HashMap<ShadowConst, ConstVal>,
map: BTreeMap<ShadowConst, ConstVal>,
}

const PROJECT_NAME: ShadowConst = "PROJECT_NAME";
Expand Down Expand Up @@ -313,7 +313,7 @@ pub fn build_time(project: &mut Project) {
);
}

pub fn new_project(std_env: &HashMap<String, String>) -> HashMap<ShadowConst, ConstVal> {
pub fn new_project(std_env: &BTreeMap<String, String>) -> BTreeMap<ShadowConst, ConstVal> {
let mut project = Project::default();
build_time(&mut project);
project.map.insert(
Expand Down
14 changes: 7 additions & 7 deletions src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::err::*;
use crate::time::BuildTime;
use crate::Format;
use chrono::SecondsFormat;
use std::collections::HashMap;
use std::collections::BTreeMap;
use std::io::{BufReader, Read};
use std::path::Path;
use std::process::{Command, Stdio};
Expand All @@ -23,7 +23,7 @@ const GIT_STATUS_FILE: ShadowConst = "GIT_STATUS_FILE";

#[derive(Default, Debug)]
pub struct Git {
map: HashMap<ShadowConst, ConstVal>,
map: BTreeMap<ShadowConst, ConstVal>,
ci_type: CiType,
}

Expand All @@ -48,7 +48,7 @@ impl Git {
}
}

fn init(&mut self, path: &Path, std_env: &HashMap<String, String>) -> SdResult<()> {
fn init(&mut self, path: &Path, std_env: &BTreeMap<String, String>) -> SdResult<()> {
// check git status
let x = command_git_clean();
self.update_bool(GIT_CLEAN, x);
Expand Down Expand Up @@ -167,7 +167,7 @@ impl Git {
}

#[allow(clippy::manual_strip)]
fn ci_branch_tag(&mut self, std_env: &HashMap<String, String>) {
fn ci_branch_tag(&mut self, std_env: &BTreeMap<String, String>) {
let mut branch: Option<String> = None;
let mut tag: Option<String> = None;
match self.ci_type {
Expand Down Expand Up @@ -211,10 +211,10 @@ impl Git {
}

pub fn new_git(
path: &std::path::Path,
path: &Path,
ci: CiType,
std_env: &HashMap<String, String>,
) -> HashMap<ShadowConst, ConstVal> {
std_env: &BTreeMap<String, String>,
) -> BTreeMap<ShadowConst, ConstVal> {
let mut git = Git {
map: Default::default(),
ci_type: ci,
Expand Down
10 changes: 5 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ use git::*;
use crate::ci::CiType;
use crate::time::BuildTime;
pub use const_format::*;
use std::collections::HashMap;
use std::collections::BTreeMap;
use std::env as std_env;
use std::fs::File;
use std::io::Write;
Expand Down Expand Up @@ -248,8 +248,8 @@ where
}

/// get std::env:vars
pub fn get_std_env() -> HashMap<String, String> {
let mut env_map = HashMap::new();
pub fn get_std_env() -> BTreeMap<String, String> {
let mut env_map = BTreeMap::new();
for (k, v) in std_env::vars() {
env_map.insert(k, v);
}
Expand All @@ -259,8 +259,8 @@ pub fn get_std_env() -> HashMap<String, String> {
#[derive(Debug)]
pub struct Shadow {
pub f: File,
pub map: HashMap<ShadowConst, ConstVal>,
pub std_env: HashMap<String, String>,
pub map: BTreeMap<ShadowConst, ConstVal>,
pub std_env: BTreeMap<String, String>,
}

impl Shadow {
Expand Down

0 comments on commit d258575

Please sign in to comment.