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  * @param out_ The user-allocated git_buf which will be filled with the
29  *     cleaned up message.
30  *
31  * @param message The message to be prettified.
32  *
33  * @param strip_comments Non-zero to remove comment lines, 0 to leave them in.
34  *
35  * @param comment_char Comment character. Lines starting with this character
36  * are considered to be comments and removed if `strip_comments` is non-zero.
37  *
38  * @return 0 or an error code.
39  */
40 //GIT_EXTERN
41 int git_message_prettify(libgit2_d.buffer.git_buf* out_, const (char)* message, int strip_comments, char comment_char);
42 
43 /**
44  * Represents a single git message trailer.
45  */
46 struct git_message_trailer
47 {
48 	const (char)* key;
49 	const (char)* value;
50 }
51 
52 /**
53  * Represents an array of git message trailers.
54  *
55  * Struct members under the private comment are private, subject to change
56  * and should not be used by callers.
57  */
58 struct git_message_trailer_array
59 {
60 	.git_message_trailer* trailers;
61 	size_t count;
62 
63 package:
64 	char* _trailer_block;
65 }
66 
67 /**
68  * Parse trailers out of a message, filling the array pointed to by +arr+.
69  *
70  * Trailers are key/value pairs in the last paragraph of a message, not
71  * including any patches or conflicts that may be present.
72  *
73  * @param arr A pre-allocated git_message_trailer_array struct to be filled in
74  *            with any trailers found during parsing.
75  * @param message The message to be parsed
76  * @return 0 on success, or non-zero on error.
77  */
78 //GIT_EXTERN
79 int git_message_trailers(.git_message_trailer_array* arr, const (char)* message);
80 
81 /**
82  * Clean's up any allocated memory in the git_message_trailer_array filled by
83  * a call to git_message_trailers.
84  */
85 //GIT_EXTERN
86 void git_message_trailer_array_free(.git_message_trailer_array* arr);
87 
88 /** @} */