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 * @param out_ new signature, in case of error null 32 * @param name name of the person 33 * @param email email of the person 34 * @param time time (in seconds from epoch) when the action happened 35 * @param offset timezone offset (in minutes) for the time 36 * @return 0 or an error code 37 */ 38 //GIT_EXTERN 39 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); 40 41 /** 42 * Create a new action signature with a timestamp of 'now'. 43 * 44 * Call `git_signature_free()` to free the data. 45 * 46 * @param out_ new signature, in case of error null 47 * @param name name of the person 48 * @param email email of the person 49 * @return 0 or an error code 50 */ 51 //GIT_EXTERN 52 int git_signature_now(libgit2_d.types.git_signature** out_, const (char)* name, const (char)* email); 53 54 /** 55 * Create a new action signature with default user and now timestamp. 56 * 57 * This looks up the user.name and user.email from the configuration and 58 * uses the current time as the timestamp, and creates a new signature 59 * based on that information. It will return git_error_code.GIT_ENOTFOUND if either the 60 * user.name or user.email are not set. 61 * 62 * @param out_ new signature 63 * @param repo repository pointer 64 * @return 0 on success, git_error_code.GIT_ENOTFOUND if config is missing, or error code 65 */ 66 //GIT_EXTERN 67 int git_signature_default(libgit2_d.types.git_signature** out_, libgit2_d.types.git_repository* repo); 68 69 /** 70 * Create a new signature by parsing the given buffer, which is 71 * expected to be in the format "Real Name <email> timestamp tzoffset", 72 * where `timestamp` is the number of seconds since the Unix epoch and 73 * `tzoffset` is the timezone offset in `hhmm` format (note the lack 74 * of a colon separator). 75 * 76 * @param out_ new signature 77 * @param buf signature string 78 * @return 0 on success, or an error code 79 */ 80 //GIT_EXTERN 81 int git_signature_from_buffer(libgit2_d.types.git_signature** out_, const (char)* buf); 82 83 /** 84 * Create a copy of an existing signature. All internal strings are also 85 * duplicated. 86 * 87 * Call `git_signature_free()` to free the data. 88 * 89 * @param dest pointer where to store the copy 90 * @param sig signature to duplicate 91 * @return 0 or an error code 92 */ 93 //GIT_EXTERN 94 int git_signature_dup(libgit2_d.types.git_signature** dest, const (libgit2_d.types.git_signature)* sig); 95 96 /** 97 * Free an existing signature. 98 * 99 * Because the signature is not an opaque structure, it is legal to free it 100 * manually, but be sure to free the "name" and "email" strings in addition 101 * to the structure itself. 102 * 103 * @param sig signature to free 104 */ 105 //GIT_EXTERN 106 void git_signature_free(libgit2_d.types.git_signature* sig); 107 108 /** @} */