@@ -141,6 +141,7 @@ impl GitStore {
141141 client. add_entity_request_handler ( Self :: handle_askpass) ;
142142 client. add_entity_request_handler ( Self :: handle_check_for_pushed_commits) ;
143143 client. add_entity_request_handler ( Self :: handle_git_diff) ;
144+ client. add_entity_request_handler ( Self :: handle_commit_history) ;
144145 }
145146
146147 pub fn active_repository ( & self ) -> Option < Entity < Repository > > {
@@ -663,6 +664,37 @@ impl GitStore {
663664 Ok ( proto:: Ack { } )
664665 }
665666
667+ async fn handle_commit_history (
668+ this : Entity < Self > ,
669+ envelope : TypedEnvelope < proto:: GitGetCommitHistory > ,
670+ mut cx : AsyncApp ,
671+ ) -> Result < proto:: GitCommitHistoryResponse > {
672+ let worktree_id = WorktreeId :: from_proto ( envelope. payload . worktree_id ) ;
673+ let work_directory_id = ProjectEntryId :: from_proto ( envelope. payload . work_directory_id ) ;
674+ let repository_handle =
675+ Self :: repository_for_request ( & this, worktree_id, work_directory_id, & mut cx) ?;
676+
677+ let commits = repository_handle
678+ . update ( & mut cx, |repository_handle, _| {
679+ repository_handle. get_commit_history ( envelope. payload . skip , envelope. payload . limit )
680+ } ) ?
681+ . await ??;
682+
683+ Ok ( proto:: GitCommitHistoryResponse {
684+ commits : commits
685+ . clone ( )
686+ . into_iter ( )
687+ . map ( |commit| proto:: GitCommitDetails {
688+ committer_name : commit. committer_name . into ( ) ,
689+ commit_timestamp : commit. commit_timestamp . into ( ) ,
690+ committer_email : commit. committer_email . into ( ) ,
691+ sha : commit. sha . into ( ) ,
692+ message : commit. message . into ( ) ,
693+ } )
694+ . collect :: < Vec < _ > > ( ) ,
695+ } )
696+ }
697+
666698 async fn handle_show (
667699 this : Entity < Self > ,
668700 envelope : TypedEnvelope < proto:: GitShow > ,
@@ -1662,6 +1694,49 @@ impl Repository {
16621694 } )
16631695 }
16641696
1697+ pub fn get_commit_history (
1698+ & self ,
1699+ skip : i32 ,
1700+ limit : i32 ,
1701+ ) -> oneshot:: Receiver < Result < Vec < CommitDetails > > > {
1702+ self . send_job ( move |repo| async move {
1703+ match repo {
1704+ GitRepo :: Local ( git_repository) => git_repository. commit_history ( skip, limit) ,
1705+ GitRepo :: Remote {
1706+ project_id,
1707+ client,
1708+ worktree_id,
1709+ work_directory_id,
1710+ } => {
1711+ let response = client
1712+ . request ( proto:: GitGetCommitHistory {
1713+ project_id : project_id. 0 ,
1714+ worktree_id : worktree_id. to_proto ( ) ,
1715+ work_directory_id : work_directory_id. to_proto ( ) ,
1716+ skip : skip,
1717+ limit : limit,
1718+ } )
1719+ . await ?;
1720+
1721+ let commits = response
1722+ . commits
1723+ . clone ( )
1724+ . into_iter ( )
1725+ . map ( |commit| CommitDetails {
1726+ committer_name : commit. committer_name . into ( ) ,
1727+ commit_timestamp : commit. commit_timestamp . into ( ) ,
1728+ committer_email : commit. committer_email . into ( ) ,
1729+ sha : commit. sha . into ( ) ,
1730+ message : commit. message . into ( ) ,
1731+ } )
1732+ . collect ( ) ;
1733+
1734+ Ok ( commits)
1735+ }
1736+ }
1737+ } )
1738+ }
1739+
16651740 pub fn diff ( & self , diff_type : DiffType , _cx : & App ) -> oneshot:: Receiver < Result < String > > {
16661741 self . send_job ( |repo| async move {
16671742 match repo {
0 commit comments