Check if repo is already cloned
This commit is contained in:
parent
ec55a274c3
commit
ed17533c02
33
src/db.rs
33
src/db.rs
|
@ -14,26 +14,35 @@ pub struct Entry {
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Task {
|
pub struct Task {
|
||||||
name: OsString,
|
pub name: OsString,
|
||||||
bin: PathBuf,
|
pub bin: PathBuf,
|
||||||
source: Option<String>,
|
pub source: Option<String>,
|
||||||
dvcs: Option<String>,
|
pub dvcs: Option<String>,
|
||||||
config: HashMap<String, String>,
|
pub config: HashMap<String, String>,
|
||||||
branch: Option<String>,
|
pub branch: Option<String>,
|
||||||
host: Option<String>
|
pub host: Option<String>,
|
||||||
|
pub cloned: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Task {
|
impl Task {
|
||||||
pub fn new(base_dir: PathBuf, name: OsString) -> Task {
|
pub fn new(base_dir: PathBuf, name: OsString) -> Task {
|
||||||
let t = Entry::new(base_dir, name.clone());
|
let t = Entry::new(base_dir, name.clone());
|
||||||
|
let source = t.source();
|
||||||
|
let cloned = source.clone().map_or(false, |src| {
|
||||||
|
let mut path = t.base_dir.clone();
|
||||||
|
path.push(format!(".{}", t.name.to_str().expect("WTF")));
|
||||||
|
path.is_dir()
|
||||||
|
});
|
||||||
Task {
|
Task {
|
||||||
name: name.clone(),
|
name: name.clone(),
|
||||||
bin: PathBuf::from(name.clone()),
|
bin: PathBuf::from(name.clone()),
|
||||||
source: t.source(),
|
source,
|
||||||
dvcs: t.dvcs(),
|
dvcs: t.dvcs(),
|
||||||
config: HashMap::new(),
|
config: HashMap::new(),
|
||||||
branch: t.branch(),
|
branch: t.branch(),
|
||||||
host: t.host(),
|
host: t.host(),
|
||||||
|
cloned,
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,6 +77,12 @@ impl Entry {
|
||||||
pub fn host(&self) -> Option<String> {
|
pub fn host(&self) -> Option<String> {
|
||||||
self.read_setting("branch")
|
self.read_setting("branch")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn has_dir(&self, name: &str) -> bool {
|
||||||
|
let mut path = self.base_dir.clone();
|
||||||
|
path.push(name);
|
||||||
|
return path.is_dir();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Database {
|
pub struct Database {
|
||||||
|
@ -111,6 +126,8 @@ impl Database {
|
||||||
Task::new(self.base_dir.clone(), path.file_name().expect("WTF").to_os_string())
|
Task::new(self.base_dir.clone(), path.file_name().expect("WTF").to_os_string())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Reads the file and strips whitespace (newline including)
|
/// Reads the file and strips whitespace (newline including)
|
||||||
|
|
Loading…
Reference in New Issue