File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -718,6 +718,15 @@ mod tests {
718
718
let pre_absorb_ref_commit = ctx. repo . refname_to_id ( "PRE_ABSORB_HEAD" ) . unwrap ( ) ;
719
719
assert_eq ! ( pre_absorb_ref_commit, actual_pre_absorb_commit) ;
720
720
721
+ assert_eq ! (
722
+ extract_commit_messages( & ctx. repo) ,
723
+ vec![
724
+ "fixup! Initial commit.\n " ,
725
+ "fixup! Initial commit.\n " ,
726
+ "Initial commit." ,
727
+ ]
728
+ ) ;
729
+
721
730
log_utils:: assert_log_messages_are (
722
731
capturing_logger. visible_logs ( ) ,
723
732
vec ! [
@@ -1814,6 +1823,23 @@ mod tests {
1814
1823
assert_eq ! ( actual_msg, expected_msg) ;
1815
1824
}
1816
1825
1826
+ /// Perform a revwalk from HEAD, extracting the commit messages.
1827
+ fn extract_commit_messages ( repo : & git2:: Repository ) -> Vec < String > {
1828
+ let mut revwalk = repo. revwalk ( ) . unwrap ( ) ;
1829
+ revwalk. push_head ( ) . unwrap ( ) ;
1830
+
1831
+ let mut messages = Vec :: new ( ) ;
1832
+
1833
+ for oid in revwalk {
1834
+ let commit = repo. find_commit ( oid. unwrap ( ) ) . unwrap ( ) ;
1835
+ if let Some ( message) = commit. message ( ) {
1836
+ messages. push ( message. to_string ( ) ) ;
1837
+ }
1838
+ }
1839
+
1840
+ messages
1841
+ }
1842
+
1817
1843
const DEFAULT_CONFIG : Config = Config {
1818
1844
dry_run : false ,
1819
1845
force_author : false ,
You can’t perform that action at this time.
0 commit comments