Initial build_on_update implementation

main
Michal 2 years ago
parent 5b87866922
commit 33689c85df
No known key found for this signature in database
GPG Key ID: A6A1A4DCB22279B9

@ -55,6 +55,10 @@ pub enum Operation {
/// The packages to operate on
#[clap(name = "package(s)", help = "The packages to operate on", action = ArgAction::Append, index = 1)]
packages: Vec<String>,
/// Does not regenerate repository after pulling given package(s). This only applies if build_on_update is set to true in repository config
#[clap(short = 'n', long = "no-regen", action = ArgAction::SetTrue)]
no_regen: bool,
},
/// Create and/or open local config file

@ -92,7 +92,9 @@ fn main() {
}
operations::build(packages, exclude.to_vec(), no_regen, verbose)
}
Operation::Pull { packages, .. } => operations::pull(packages, exclude.to_vec(), verbose),
Operation::Pull {
packages, no_regen, ..
} => operations::pull(packages, exclude.to_vec(), verbose, no_regen),
Operation::RepoGen => {
if !repository {
crash!(

@ -4,7 +4,13 @@ use std::process::Command;
use crate::info;
use crate::{crash, internal::AppExitCode, log, workspace::read_cfg};
fn do_the_pulling(repos: Vec<String>, verbose: bool, smart_pull: bool, build_on_update: bool) {
fn do_the_pulling(
repos: Vec<String>,
verbose: bool,
smart_pull: bool,
build_on_update: bool,
no_regen: bool,
) {
for repo in repos {
// Set root dir to return after each git pull
let root_dir = env::current_dir().unwrap();
@ -12,9 +18,11 @@ fn do_the_pulling(repos: Vec<String>, verbose: bool, smart_pull: bool, build_on_
// Enter repo dir
info!("Entering working directory: {}", &repo);
env::set_current_dir(repo).unwrap();
env::set_current_dir(&repo).unwrap();
log!(verbose, "Current dir: {:?}", env::current_dir().unwrap());
let mut packages_to_rebuild: Vec<String> = vec![];
// Pull
log!(verbose, "Pulling");
if smart_pull {
@ -46,7 +54,9 @@ fn do_the_pulling(repos: Vec<String>, verbose: bool, smart_pull: bool, build_on_
// If build_on_update is set, rebuild package
if build_on_update {
unimplemented!() // TODO: Implement build_on_update
info!("Package {} updated, staging for rebuild", &repo);
log!(verbose, "Pushing package {} to be rebuilt", &repo);
packages_to_rebuild.push(repo);
}
} else {
// If there are no changes, alert the user
@ -69,10 +79,17 @@ fn do_the_pulling(repos: Vec<String>, verbose: bool, smart_pull: bool, build_on_
"Returned to root dir: {:?}",
env::current_dir().unwrap()
);
if !packages_to_rebuild.is_empty() && build_on_update {
info!("Rebuilding packages: {}", &packages_to_rebuild.join(", "));
log!(verbose, "Rebuilding packages: {:?}", &packages_to_rebuild);
crate::operations::build(packages_to_rebuild, vec![], no_regen, verbose);
}
}
}
pub fn pull(packages: Vec<String>, exclude: Vec<String>, verbose: bool) {
pub fn pull(packages: Vec<String>, exclude: Vec<String>, verbose: bool, no_regen: bool) {
// Read config file
let config = read_cfg(verbose);
log!(verbose, "Config: {:?}", config);
@ -114,5 +131,11 @@ pub fn pull(packages: Vec<String>, exclude: Vec<String>, verbose: bool) {
// Pull!
log!(verbose, "Pulling {:?}", repos_applicable);
do_the_pulling(repos_applicable, verbose, smart_pull, build_on_update);
do_the_pulling(
repos_applicable,
verbose,
smart_pull,
build_on_update,
no_regen,
);
}

Loading…
Cancel
Save