@@ -583,6 +583,33 @@ static VALUE rb_git_commit_header_field(VALUE self, VALUE rb_field) {
583
583
return rb_result ;
584
584
}
585
585
586
+ /*
587
+ * call-seq:
588
+ * commit.header_field?(field_name) -> bool
589
+ *
590
+ * Returns true if header field is present, false otherwise.
591
+ */
592
+ static VALUE rb_git_commit_header_field_present (VALUE self , VALUE rb_field ) {
593
+ git_buf header_field = { 0 };
594
+ git_commit * commit ;
595
+ int err ;
596
+
597
+ Check_Type (rb_field , T_STRING );
598
+
599
+ Data_Get_Struct (self , git_commit , commit );
600
+
601
+ err = git_commit_header_field (& header_field , commit , StringValueCStr (rb_field ));
602
+
603
+ git_buf_free (& header_field );
604
+
605
+ if (err == GIT_ENOTFOUND )
606
+ return Qfalse ;
607
+
608
+ rugged_exception_check (err );
609
+
610
+ return Qtrue ;
611
+ }
612
+
586
613
/*
587
614
* call-seq:
588
615
* commit.header -> str
@@ -627,5 +654,6 @@ void Init_rugged_commit(void)
627
654
rb_define_method (rb_cRuggedCommit , "to_mbox" , rb_git_commit_to_mbox , -1 );
628
655
629
656
rb_define_method (rb_cRuggedCommit , "header_field" , rb_git_commit_header_field , 1 );
657
+ rb_define_method (rb_cRuggedCommit , "header_field?" , rb_git_commit_header_field_present , 1 );
630
658
rb_define_method (rb_cRuggedCommit , "header" , rb_git_commit_header , 0 );
631
659
}
0 commit comments