1 /* 2 * Copyright (C) the libgit2 contributors. All rights reserved. 3 * 4 * This file is part of libgit2, distributed under the GNU GPL v2 with 5 * a Linking Exception. For full terms see the included COPYING file. 6 */ 7 module libgit2_d.message; 8 9 10 private static import libgit2_d.buffer; 11 12 /** 13 * @file git2/message.h 14 * @brief Git message management routines 15 * @ingroup Git 16 * @{ 17 */ 18 extern (C): 19 nothrow @nogc: 20 public: 21 22 /** 23 * Clean up excess whitespace and make sure there is a trailing newline in the 24 * message. 25 * 26 * Optionally, it can remove lines which start with the comment character. 27 * 28 * Params: 29 * out_ = The user-allocated git_buf which will be filled with the cleaned up message. 30 * message = The message to be prettified. 31 * strip_comments = Non-zero to remove comment lines, 0 to leave them in. 32 * comment_char = Comment character. Lines starting with this character are considered to be comments and removed if `strip_comments` is non-zero. 33 * 34 * Returns: 0 or an error code. 35 */ 36 //GIT_EXTERN 37 int git_message_prettify(libgit2_d.buffer.git_buf* out_, const (char)* message, int strip_comments, char comment_char); 38 39 /** 40 * Represents a single git message trailer. 41 */ 42 struct git_message_trailer 43 { 44 const (char)* key; 45 const (char)* value; 46 } 47 48 /** 49 * Represents an array of git message trailers. 50 * 51 * Struct members under the private comment are private, subject to change 52 * and should not be used by callers. 53 */ 54 struct git_message_trailer_array 55 { 56 .git_message_trailer* trailers; 57 size_t count; 58 59 package: 60 char* _trailer_block; 61 } 62 63 /** 64 * Parse trailers out of a message, filling the array pointed to by +arr+. 65 * 66 * Trailers are key/value pairs in the last paragraph of a message, not 67 * including any patches or conflicts that may be present. 68 * 69 * Params: 70 * arr = A pre-allocated git_message_trailer_array struct to be filled in with any trailers found during parsing. 71 * message = The message to be parsed 72 * 73 * Returns: 0 on success, or non-zero on error. 74 */ 75 //GIT_EXTERN 76 int git_message_trailers(.git_message_trailer_array* arr, const (char)* message); 77 78 /** 79 * Clean's up any allocated memory in the git_message_trailer_array filled by 80 * a call to git_message_trailers. 81 */ 82 //GIT_EXTERN 83 void git_message_trailer_array_free(.git_message_trailer_array* arr); 84 85 /** @} */