@@ -589,6 +589,33 @@ static VALUE rb_git_commit_header_field(VALUE self, VALUE rb_field) {
589
589
return rb_result ;
590
590
}
591
591
592
+ /*
593
+ * call-seq:
594
+ * commit.header_field?(field_name) -> bool
595
+ *
596
+ * Returns true if header field is present, false otherwise.
597
+ */
598
+ static VALUE rb_git_commit_header_field_present (VALUE self , VALUE rb_field ) {
599
+ git_buf header_field = { 0 };
600
+ git_commit * commit ;
601
+ int error ;
602
+
603
+ Check_Type (rb_field , T_STRING );
604
+
605
+ Data_Get_Struct (self , git_commit , commit );
606
+
607
+ error = git_commit_header_field (& header_field , commit , StringValueCStr (rb_field ));
608
+
609
+ git_buf_free (& header_field );
610
+
611
+ if (error == GIT_ENOTFOUND )
612
+ return Qfalse ;
613
+
614
+ rugged_exception_check (error );
615
+
616
+ return Qtrue ;
617
+ }
618
+
592
619
/*
593
620
* call-seq:
594
621
* commit.header -> str
@@ -633,5 +660,6 @@ void Init_rugged_commit(void)
633
660
rb_define_method (rb_cRuggedCommit , "to_mbox" , rb_git_commit_to_mbox , -1 );
634
661
635
662
rb_define_method (rb_cRuggedCommit , "header_field" , rb_git_commit_header_field , 1 );
663
+ rb_define_method (rb_cRuggedCommit , "header_field?" , rb_git_commit_header_field_present , 1 );
636
664
rb_define_method (rb_cRuggedCommit , "header" , rb_git_commit_header , 0 );
637
665
}
0 commit comments