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 /**
8  * License: GPL-2.0(Linking Exception)
9  */
10 module libgit2.message;
11 
12 
13 private static import libgit2.buffer;
14 private import libgit2.common: GIT_EXTERN;
15 
16 /*
17  * @file git2/message.h
18  * @brief Git message management routines
19  * @ingroup Git
20  * @{
21  */
22 extern (C):
23 nothrow @nogc:
24 public:
25 
26 /**
27  * Clean up excess whitespace and make sure there is a trailing newline in the
28  * message.
29  *
30  * Optionally, it can remove lines which start with the comment character.
31  *
32  * Params:
33  *      out_ = The user-allocated git_buf which will be filled with the cleaned up message.
34  *      message = The message to be prettified.
35  *      strip_comments = Non-zero to remove comment lines, 0 to leave them in.
36  *      comment_char = Comment character. Lines starting with this character are considered to be comments and removed if `strip_comments` is non-zero.
37  *
38  * Returns: 0 or an error code.
39  */
40 @GIT_EXTERN
41 int git_message_prettify(libgit2.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  * Params:
74  *      arr = A pre-allocated git_message_trailer_array struct to be filled in with any trailers found during parsing.
75  *      message = The message to be parsed
76  *
77  * Returns: 0 on success, or non-zero on error.
78  */
79 @GIT_EXTERN
80 int git_message_trailers(.git_message_trailer_array* arr, const (char)* message);
81 
82 /**
83  * Clean's up any allocated memory in the git_message_trailer_array filled by
84  * a call to git_message_trailers.
85  *
86  * Params:
87  *      arr = The trailer to free.
88  */
89 @GIT_EXTERN
90 void git_message_trailer_array_free(.git_message_trailer_array* arr);
91 
92 /* @} */