File tree Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -159,6 +159,32 @@ impl josh::cache::FilterHook for GitNotesFilterHook {
159159 }
160160}
161161
162+ struct ChangeIdFilterHook {
163+ repo : std:: sync:: Mutex < git2:: Repository > ,
164+ }
165+
166+ impl josh:: cache:: FilterHook for ChangeIdFilterHook {
167+ fn filter_for_commit (
168+ & self ,
169+ commit_oid : git2:: Oid ,
170+ arg : & str ,
171+ ) -> josh:: JoshResult < josh:: filter:: Filter > {
172+ let repo = self . repo . lock ( ) . unwrap ( ) ;
173+ let commit = repo. find_commit ( commit_oid) ?;
174+ let data = format ! (
175+ "{:?}:{:?}:{}:{}" ,
176+ commit. message( ) ,
177+ commit. time( ) ,
178+ commit. author( ) ,
179+ commit. committer( )
180+ ) ;
181+
182+ let hash = git2:: Oid :: hash_object ( git2:: ObjectType :: Blob , data. as_bytes ( ) )
183+ . expect ( "hash_object changeid" ) ;
184+ josh:: filter:: parse ( & format ! ( ":\" {}\" " , hash) )
185+ }
186+ }
187+
162188fn run_filter ( args : Vec < String > ) -> josh:: JoshResult < i32 > {
163189 let args = make_app ( ) . get_matches_from ( args) ;
164190
@@ -200,7 +226,7 @@ fn run_filter(args: Vec<String>) -> josh::JoshResult<i32> {
200226 git2:: RepositoryOpenFlags :: NO_SEARCH ,
201227 & [ ] as & [ & std:: ffi:: OsStr ] ,
202228 ) ?;
203- let hook = GitNotesFilterHook {
229+ let hook = ChangeIdFilterHook {
204230 repo : std:: sync:: Mutex :: new ( repo_for_hook) ,
205231 } ;
206232 transaction = transaction. with_filter_hook ( std:: sync:: Arc :: new ( hook) ) ;
You can’t perform that action at this time.
0 commit comments