WIP sync file by repo
This commit is contained in:
parent
fa9f35bfac
commit
ad677d22ce
3 changed files with 412 additions and 1 deletions
|
|
@ -189,13 +189,17 @@ impl FirmwareFilterOptions {
|
|||
|
||||
pub struct XBuilder {
|
||||
saved_firmwares: Vec<LastBuildFirmware>,
|
||||
base: Option<LastBuildFirmware>,
|
||||
}
|
||||
|
||||
impl XBuilder {
|
||||
pub fn new() -> Self {
|
||||
let saved_firmwares = read_last_build_firmwares().unwrap_or(Vec::new());
|
||||
|
||||
Self { saved_firmwares }
|
||||
Self {
|
||||
saved_firmwares,
|
||||
base: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_latest_by_options(
|
||||
|
|
@ -266,4 +270,53 @@ impl XBuilder {
|
|||
|
||||
result
|
||||
}
|
||||
|
||||
pub fn set_base(&mut self, fwb: LastBuildFirmware) {
|
||||
//
|
||||
let mut base = fwb.clone();
|
||||
if base.entries.is_empty() {
|
||||
base.update_entries().unwrap();
|
||||
}
|
||||
|
||||
self.base = Some(base);
|
||||
}
|
||||
|
||||
/// get last commit that should add to file
|
||||
pub fn sync_file_list(&mut self) -> Vec<String> {
|
||||
let mut result = Vec::new();
|
||||
|
||||
// get config
|
||||
let ucfg = common::get_config();
|
||||
let taobin_repo = ucfg
|
||||
.get("TAOBIN_REPO")
|
||||
.expect("Unknown git directory, check .tbcfg");
|
||||
|
||||
let git_res = git2::Repository::open(taobin_repo);
|
||||
|
||||
let last_build_from_base = self.base.as_ref().unwrap().date.timestamp();
|
||||
|
||||
match git_res {
|
||||
Ok(repo) => {
|
||||
let mut revwalk = repo.revwalk().expect("Failed to create revwalk");
|
||||
for cid in revwalk {
|
||||
let commit_id = cid.expect("Failed to get commit id");
|
||||
let commit = repo.find_commit(commit_id).expect("Failed to find commit");
|
||||
|
||||
let commit_time = commit.time();
|
||||
if commit_time.seconds() >= last_build_from_base {
|
||||
println!(
|
||||
"Commit {} [{}]",
|
||||
commit.id(),
|
||||
commit.message().unwrap_or("-")
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("Error while trying to open repo, {:?}", e);
|
||||
}
|
||||
}
|
||||
|
||||
result
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue