Compare commits
2 Commits
b3bf0b99b9
...
14f8209be3
| Author | SHA1 | Date | |
|---|---|---|---|
| 14f8209be3 | |||
| db51056cd1 |
19
src/git.rs
19
src/git.rs
@@ -1,5 +1,24 @@
|
|||||||
|
use std::path::PathBuf;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
|
pub fn get_git_base_path() -> Option<PathBuf> {
|
||||||
|
match PathBuf::from(".").canonicalize() {
|
||||||
|
Err(e) => {
|
||||||
|
warn!("Get current path failed: {}", e);
|
||||||
|
None
|
||||||
|
},
|
||||||
|
Ok(mut path) => loop {
|
||||||
|
if path.join(".git").is_dir() {
|
||||||
|
debug!("Found git base dir: {:?}", path)
|
||||||
|
return Some(path);
|
||||||
|
}
|
||||||
|
if !path.pop() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn check_git_status() -> bool {
|
pub fn check_git_status() -> bool {
|
||||||
trace!("Run: git fetch --dry-run");
|
trace!("Run: git fetch --dry-run");
|
||||||
match Command::new("git").env("LANG", "en_US").args(&["fetch", "--dry-run"]).output() {
|
match Command::new("git").env("LANG", "en_US").args(&["fetch", "--dry-run"]).output() {
|
||||||
|
|||||||
@@ -1,5 +1,27 @@
|
|||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
use serde::{ Deserialize, Serialize };
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
pub struct ScriptDescription {
|
||||||
|
pub name: String,
|
||||||
|
pub version: String,
|
||||||
|
pub hash: String,
|
||||||
|
pub repo: String,
|
||||||
|
#[serde(rename = "gitHash")]
|
||||||
|
pub git_hash: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
pub struct ScriptConfig {
|
||||||
|
pub repo: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
pub struct ScriptLocalConfig {
|
||||||
|
#[serde(rename = "indexPath")]
|
||||||
|
pub index_path: String,
|
||||||
|
}
|
||||||
|
|
||||||
pub fn _get_script_base_path(base: &PathBuf, file_name: &str) -> PathBuf {
|
pub fn _get_script_base_path(base: &PathBuf, file_name: &str) -> PathBuf {
|
||||||
let mut fn_chars = file_name.chars().take_while(|c| *c != '.');
|
let mut fn_chars = file_name.chars().take_while(|c| *c != '.');
|
||||||
|
|||||||
Reference in New Issue
Block a user