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.signature; 8 9 10 private static import libgit2_d.types; 11 12 /** 13 * @file git2/signature.h 14 * @brief Git signature creation 15 * @defgroup libgit2_d.types.git_signature Git signature creation 16 * @ingroup Git 17 * @{ 18 */ 19 extern (C): 20 nothrow @nogc: 21 public: 22 23 /** 24 * Create a new action signature. 25 * 26 * Call `git_signature_free()` to free the data. 27 * 28 * Note: angle brackets ('<' and '>') characters are not allowed 29 * to be used in either the `name` or the `email` parameter. 30 * 31 * Params: 32 * out_ = new signature, in case of error null 33 * name = name of the person 34 * email = email of the person 35 * time = time (in seconds from epoch) when the action happened 36 * offset = timezone offset (in minutes) for the time 37 * 38 * Returns: 0 or an error code 39 */ 40 //GIT_EXTERN 41 int git_signature_new(libgit2_d.types.git_signature** out_, const (char)* name, const (char)* email, libgit2_d.types.git_time_t time, int offset); 42 43 /** 44 * Create a new action signature with a timestamp of 'now'. 45 * 46 * Call `git_signature_free()` to free the data. 47 * 48 * Params: 49 * out_ = new signature, in case of error null 50 * name = name of the person 51 * email = email of the person 52 * 53 * Returns: 0 or an error code 54 */ 55 //GIT_EXTERN 56 int git_signature_now(libgit2_d.types.git_signature** out_, const (char)* name, const (char)* email); 57 58 /** 59 * Create a new action signature with default user and now timestamp. 60 * 61 * This looks up the user.name and user.email from the configuration and 62 * uses the current time as the timestamp, and creates a new signature 63 * based on that information. It will return git_error_code.GIT_ENOTFOUND if either the 64 * user.name or user.email are not set. 65 * 66 * Params: 67 * out_ = new signature 68 * repo = repository pointer 69 * 70 * Returns: 0 on success, git_error_code.GIT_ENOTFOUND if config is missing, or error code 71 */ 72 //GIT_EXTERN 73 int git_signature_default(libgit2_d.types.git_signature** out_, libgit2_d.types.git_repository* repo); 74 75 /** 76 * Create a new signature by parsing the given buffer, which is 77 * expected to be in the format "Real Name <email> timestamp tzoffset", 78 * where `timestamp` is the number of seconds since the Unix epoch and 79 * `tzoffset` is the timezone offset in `hhmm` format (note the lack 80 * of a colon separator). 81 * 82 * Params: 83 * out_ = new signature 84 * buf = signature string 85 * 86 * Returns: 0 on success, or an error code 87 */ 88 //GIT_EXTERN 89 int git_signature_from_buffer(libgit2_d.types.git_signature** out_, const (char)* buf); 90 91 /** 92 * Create a copy of an existing signature. All internal strings are also 93 * duplicated. 94 * 95 * Call `git_signature_free()` to free the data. 96 * 97 * Params: 98 * dest = pointer where to store the copy 99 * sig = signature to duplicate 100 * 101 * Returns: 0 or an error code 102 */ 103 //GIT_EXTERN 104 int git_signature_dup(libgit2_d.types.git_signature** dest, const (libgit2_d.types.git_signature)* sig); 105 106 /** 107 * Free an existing signature. 108 * 109 * Because the signature is not an opaque structure, it is legal to free it 110 * manually, but be sure to free the "name" and "email" strings in addition 111 * to the structure itself. 112 * 113 * Params: 114 * sig = signature to free 115 */ 116 //GIT_EXTERN 117 void git_signature_free(libgit2_d.types.git_signature* sig); 118 119 /** @} */