got the revwalker working.
This commit is contained in:
parent
0293018f85
commit
dd63558560
19
src/args.rs
19
src/args.rs
|
@ -1,13 +1,9 @@
|
|||
#![allow(dead_code)]
|
||||
use crate::err::GitErrors;
|
||||
use chrono::prelude::*;
|
||||
use chrono::NaiveDateTime;
|
||||
use chrono::{prelude::*, NaiveDateTime};
|
||||
use chrono_tz::Tz;
|
||||
use clap::Parser;
|
||||
use git2::Commit;
|
||||
use git2::Oid;
|
||||
use git2::Repository;
|
||||
use git2::Sort;
|
||||
use git2::{Oid, Repository, Sort};
|
||||
|
||||
use crate::time::DateTimeRange;
|
||||
|
||||
|
@ -34,6 +30,7 @@ pub(crate) struct Cli {
|
|||
pub(crate) timezone: Option<chrono_tz::Tz>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct ProgramOptions {
|
||||
pub(crate) start_time: DateTime<Tz>,
|
||||
pub(crate) end_time: DateTime<Tz>,
|
||||
|
@ -83,15 +80,15 @@ impl TryFrom<Cli> for ProgramOptions {
|
|||
let mut sorting = Sort::REVERSE;
|
||||
sorting.insert(Sort::TOPOLOGICAL);
|
||||
sorting.insert(Sort::TIME);
|
||||
let mut revwalker = repo.revwalk().unwrap();
|
||||
revwalker.set_sorting(sorting).unwrap();
|
||||
revwalker.simplify_first_parent().unwrap();
|
||||
revwalker.next().unwrap().unwrap()
|
||||
let mut revwalker = repo.revwalk().expect("could not construct revwalker");
|
||||
revwalker.push_head().expect("could not push head");
|
||||
revwalker.set_sorting(sorting).expect("could not set revwalker sorting");
|
||||
revwalker.next().expect("revwalker is empty").expect("IDK what this error is")
|
||||
};
|
||||
Ok(ProgramOptions {
|
||||
start_time,
|
||||
end_time,
|
||||
allowed_times: todo!(),
|
||||
allowed_times: Vec::new(),
|
||||
first_commit,
|
||||
last_commit,
|
||||
})
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#![allow(dead_code)]
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
|
|
|
@ -24,7 +24,7 @@ pub fn rebase_commits_across_timerange<Tz: chrono::TimeZone>(
|
|||
ranges: &[DateTimeRange<Tz>],
|
||||
max_jitter: &Duration,
|
||||
) -> Result<(), GitErrors> {
|
||||
let num_commits = get_no_of_commits(&start_commit, &end_commit)?;
|
||||
let num_commits = get_no_of_commits(start_commit, end_commit)?;
|
||||
let times = distribute_across_ranges_with_jitter(ranges, num_commits, max_jitter);
|
||||
todo!()
|
||||
}
|
||||
|
|
14
src/main.rs
14
src/main.rs
|
@ -3,15 +3,11 @@ mod err;
|
|||
mod git;
|
||||
mod time;
|
||||
|
||||
use chrono::prelude::*;
|
||||
use chrono_tz::Tz;
|
||||
use clap::Parser;
|
||||
use err::GitErrors;
|
||||
|
||||
fn main() {
|
||||
let cli = args::Cli::parse();
|
||||
println!("{:#?}", cli);
|
||||
println!(
|
||||
"start_time = {:#?}, end_time = {:#?}, tz = {:#?}",
|
||||
start_time, end_time, tz
|
||||
)
|
||||
fn main() -> Result<(), GitErrors>{
|
||||
let options: args::ProgramOptions = args::Cli::parse().try_into().unwrap();
|
||||
println!("{:#?}", options);
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -17,8 +17,8 @@ impl<Tz: chrono::TimeZone> DateTimeRange<Tz> {
|
|||
) -> Option<DateTimeRange<Tz>> {
|
||||
if self.is_in_range(&other.start) || self.is_in_range(&other.end) {
|
||||
Some(DateTimeRange {
|
||||
start: self.start.max(other.start),
|
||||
end: self.end.min(other.end),
|
||||
start: self.start.clone().max(other.start.clone()),
|
||||
end: self.end.clone().min(other.end.clone()),
|
||||
})
|
||||
} else {
|
||||
None
|
||||
|
|
Loading…
Reference in a new issue