now lets you pull specific packages & added reinit

main
jan Michal 3 years ago
parent b3913e9120
commit ef6a0bc483
No known key found for this signature in database
GPG Key ID: CB521D73AA05EBF2

@ -1,6 +1,6 @@
[package] [package]
name = "Malachite" name = "Malachite"
version = "0.1.0" version = "1.1.0"
authors = [ "michal <michal@tar.black>" ] authors = [ "michal <michal@tar.black>" ]
edition = "2021" edition = "2021"
description = "Packaging tool for pacman repositories" description = "Packaging tool for pacman repositories"

@ -1,7 +1,7 @@
# Maintainer: Matt C <mdc028[at]bucknell[dot]edu> # Maintainer: Matt C <mdc028[at]bucknell[dot]edu>
pkgname=malachite pkgname=malachite
pkgver=1.0.0 pkgver=1.1.0
pkgrel=1 pkgrel=1
pkgdesc="Tool for packaging and maintaining pacman repositories" pkgdesc="Tool for packaging and maintaining pacman repositories"
arch=('any') arch=('any')

@ -76,10 +76,20 @@ fn main() {
.subcommand(SubCommand::with_name("init").about( .subcommand(SubCommand::with_name("init").about(
"Clones all git repositories from mlc.toml branching from current directory", "Clones all git repositories from mlc.toml branching from current directory",
)) ))
.subcommand(SubCommand::with_name("reinit"))
.about("Removes all subdirectories and reinitialises")
.subcommand( .subcommand(
SubCommand::with_name("pull").alias("update").about( SubCommand::with_name("pull")
"Pulls all git repositories from mlc.toml branching from current directory", .alias("update")
), .about(
"Pulls all git repositories from mlc.toml branching from current directory",
)
.arg(
Arg::with_name("package(s)")
.help("The packages to operate on")
.multiple(true)
.index(1),
),
) )
.subcommand( .subcommand(
SubCommand::with_name("config").about("Create and/or open local config file"), SubCommand::with_name("config").about("Create and/or open local config file"),
@ -148,6 +158,39 @@ fn main() {
} }
} }
if let true = matches.is_present("reinit") {
let config = workspace::read_cfg();
Command::new("bash")
.args(&["-c", "rm -rf */"])
.spawn()
.unwrap()
.wait()
.unwrap();
if config.mode == "workspace" {
for r in config.repo {
info(format!("Cloning (workspace mode): {}", r));
Command::new("git")
.args(&["clone", &r])
.spawn()
.unwrap()
.wait()
.unwrap();
}
} else if config.mode == "repository" {
for r in config.repo {
info(format!("Cloning (repository mode): {}", r));
Command::new("git")
.args(&["clone", &r])
.spawn()
.unwrap()
.wait()
.unwrap();
}
} else {
crash("Invalid mode in mlc.toml".to_string(), 1);
}
}
if let true = matches.is_present("build") { if let true = matches.is_present("build") {
let config = workspace::read_cfg(); let config = workspace::read_cfg();
let mut packages: Vec<String> = matches let mut packages: Vec<String> = matches
@ -215,23 +258,47 @@ fn main() {
} }
if let true = matches.is_present("pull") { if let true = matches.is_present("pull") {
let packages: Vec<String> = matches
.subcommand_matches("pull")
.unwrap()
.values_of_lossy("package(s)")
.unwrap_or_default();
let config = workspace::read_cfg(); let config = workspace::read_cfg();
let cdir = env::current_dir().unwrap(); let cdir = env::current_dir().unwrap();
for r in config.repo { if packages.is_empty() {
info(format!("Entering working directory: {}", r)); for r in config.repo {
let dir = format!( info(format!("Entering working directory: {}", r));
"{}/{}", let dir = format!(
env::current_dir().unwrap().display(), "{}/{}",
r.split('/').collect::<Vec<&str>>().last().unwrap() env::current_dir().unwrap().display(),
); r.split('/').collect::<Vec<&str>>().last().unwrap()
env::set_current_dir(dir).unwrap(); );
Command::new("git") env::set_current_dir(dir).unwrap();
.args(&["pull", &r]) Command::new("git")
.spawn() .args(&["pull", &r])
.unwrap() .spawn()
.wait() .unwrap()
.unwrap(); .wait()
env::set_current_dir(&cdir).unwrap(); .unwrap();
env::set_current_dir(&cdir).unwrap();
}
} else {
for r in packages {
info(format!("Entering working directory: {}", r));
let dir = format!(
"{}/{}",
env::current_dir().unwrap().display(),
r.split('/').collect::<Vec<&str>>().last().unwrap()
);
env::set_current_dir(dir).unwrap();
Command::new("git")
.args(&["pull", &r])
.spawn()
.unwrap()
.wait()
.unwrap();
env::set_current_dir(&cdir).unwrap();
}
} }
} }

Loading…
Cancel
Save