Skip to content

Is there any way to get last commit of a certain file? #859

Closed Answered by cathaysia
cathaysia asked this question in Q&A
Discussion options

You must be logged in to vote

thanks to #613 , then I'm able to get all file's last modify time:

   fn new(repo_dir: &str) -> Option<Self> {
        let repo = ThreadSafeRepository::discover(repo_dir)
            .ok()?
            .to_thread_local();
        let rewalk = repo.rev_walk(Some(repo.head_id().unwrap().detach()));
        let mut changes = rewalk.all().ok()?.filter_map(Result::ok);
        let mut mtimes: HashMap<String, u32> = HashMap::new();
        let mut last = Self::id_to_commit(changes.next()?.id())?;
        for next in changes {
            let next_shad = Self::id_to_commit(next.id()).unwrap();
            match Self::change_from_commit(&last, Some(&next_shad)) {
                Some((time, set))

Replies: 3 comments 8 replies

Comment options

You must be logged in to vote
8 replies
@Byron
Comment options

@cathaysia
Comment options

@Byron
Comment options

@cathaysia
Comment options

@cathaysia
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by cathaysia
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants