use crate::{
    bare::GitBare,
    cmd::{
        commit::{
            CommitMeta,
            commit_walker::{CommitWalkParams, CommitWalkSort},
        },
        oid::ObjectId,
    },
    errors::GitResult,
};

impl GitBare {
    pub fn commit_history(
        &self,
        params: CommitWalkParams,
    ) -> GitResult<Vec<CommitMeta>> {
        self.commit_walk(params)
    }

    pub fn commit_history_head(
        &self,
        limit: Option<usize>,
    ) -> GitResult<Vec<CommitMeta>> {
        let mut params = CommitWalkParams::default();
        params.start_oids = vec![ObjectId::new("HEAD")];
        params.limit = limit;
        params.sort = CommitWalkSort::Time;
        self.commit_history(params)
    }
}
