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.tag; 8 9 10 private static import libgit2_d.oid; 11 private static import libgit2_d.strarray; 12 private static import libgit2_d.types; 13 14 /** 15 * @file git2/tag.h 16 * @brief Git tag parsing routines 17 * @defgroup git_tag Git tag management 18 * @ingroup Git 19 * @{ 20 */ 21 extern (C): 22 nothrow @nogc: 23 public: 24 25 /** 26 * Lookup a tag object from the repository. 27 * 28 * Params: 29 * out_ = pointer to the looked up tag 30 * repo = the repo to use when locating the tag. 31 * id = identity of the tag to locate. 32 * 33 * Returns: 0 or an error code 34 */ 35 //GIT_EXTERN 36 int git_tag_lookup(libgit2_d.types.git_tag** out_, libgit2_d.types.git_repository* repo, const (libgit2_d.oid.git_oid)* id); 37 38 /** 39 * Lookup a tag object from the repository, 40 * given a prefix of its identifier (short id). 41 * 42 * @see git_object_lookup_prefix 43 * 44 * Params: 45 * out_ = pointer to the looked up tag 46 * repo = the repo to use when locating the tag. 47 * id = identity of the tag to locate. 48 * len = the length of the short identifier 49 * 50 * Returns: 0 or an error code 51 */ 52 //GIT_EXTERN 53 int git_tag_lookup_prefix(libgit2_d.types.git_tag** out_, libgit2_d.types.git_repository* repo, const (libgit2_d.oid.git_oid)* id, size_t len); 54 55 /** 56 * Close an open tag 57 * 58 * You can no longer use the git_tag pointer after this call. 59 * 60 * IMPORTANT: You MUST call this method when you are through with a tag to 61 * release memory. Failure to do so will cause a memory leak. 62 * 63 * Params: 64 * tag = the tag to close 65 */ 66 //GIT_EXTERN 67 void git_tag_free(libgit2_d.types.git_tag* tag); 68 69 /** 70 * Get the id of a tag. 71 * 72 * Params: 73 * tag = a previously loaded tag. 74 * 75 * Returns: object identity for the tag. 76 */ 77 //GIT_EXTERN 78 const (libgit2_d.oid.git_oid)* git_tag_id(const (libgit2_d.types.git_tag)* tag); 79 80 /** 81 * Get the repository that contains the tag. 82 * 83 * Params: 84 * tag = A previously loaded tag. 85 * 86 * Returns: Repository that contains this tag. 87 */ 88 //GIT_EXTERN 89 libgit2_d.types.git_repository* git_tag_owner(const (libgit2_d.types.git_tag)* tag); 90 91 /** 92 * Get the tagged object of a tag 93 * 94 * This method performs a repository lookup for the 95 * given object and returns it 96 * 97 * Params: 98 * target_out = pointer where to store the target 99 * tag = a previously loaded tag. 100 * 101 * Returns: 0 or an error code 102 */ 103 //GIT_EXTERN 104 int git_tag_target(libgit2_d.types.git_object** target_out, const (libgit2_d.types.git_tag)* tag); 105 106 /** 107 * Get the OID of the tagged object of a tag 108 * 109 * Params: 110 * tag = a previously loaded tag. 111 * 112 * Returns: pointer to the OID 113 */ 114 //GIT_EXTERN 115 const (libgit2_d.oid.git_oid)* git_tag_target_id(const (libgit2_d.types.git_tag)* tag); 116 117 /** 118 * Get the type of a tag's tagged object 119 * 120 * Params: 121 * tag = a previously loaded tag. 122 * 123 * Returns: type of the tagged object 124 */ 125 //GIT_EXTERN 126 libgit2_d.types.git_object_t git_tag_target_type(const (libgit2_d.types.git_tag)* tag); 127 128 /** 129 * Get the name of a tag 130 * 131 * Params: 132 * tag = a previously loaded tag. 133 * 134 * Returns: name of the tag 135 */ 136 //GIT_EXTERN 137 const (char)* git_tag_name(const (libgit2_d.types.git_tag)* tag); 138 139 /** 140 * Get the tagger (author) of a tag 141 * 142 * Params: 143 * tag = a previously loaded tag. 144 * 145 * Returns: reference to the tag's author or null when unspecified 146 */ 147 //GIT_EXTERN 148 const (libgit2_d.types.git_signature)* git_tag_tagger(const (libgit2_d.types.git_tag)* tag); 149 150 /** 151 * Get the message of a tag 152 * 153 * Params: 154 * tag = a previously loaded tag. 155 * 156 * Returns: message of the tag or null when unspecified 157 */ 158 //GIT_EXTERN 159 const (char)* git_tag_message(const (libgit2_d.types.git_tag)* tag); 160 161 /** 162 * Create a new tag in the repository from an object 163 * 164 * A new reference will also be created pointing to 165 * this tag object. If `force` is true and a reference 166 * already exists with the given name, it'll be replaced. 167 * 168 * The message will not be cleaned up. This can be achieved 169 * through `git_message_prettify()`. 170 * 171 * The tag name will be checked for validity. You must avoid 172 * the characters '~', '^', ':', '\\', '?', '[', and '*', and the 173 * sequences ".." and "@{" which have special meaning to revparse. 174 * 175 * Params: 176 * oid = Pointer where to store the OID of the newly created tag. If the tag already exists, this parameter will be the oid of the existing tag, and the function will return a git_error_code.GIT_EEXISTS error code. 177 * 178 * Params: 179 * repo = Repository where to store the tag 180 * tag_name = Name for the tag; this name is validated for consistency. It should also not conflict with an already existing tag name 181 * target = Object to which this tag points. This object must belong to the given `repo`. 182 * tagger = Signature of the tagger for this tag, and of the tagging time 183 * message = Full message for this tag 184 * force = Overwrite existing references 185 * 186 * Returns: 0 on success, git_error_code.GIT_EINVALIDSPEC or an error code A tag object is written to the ODB, and a proper reference is written in the /refs/tags folder, pointing to it 187 */ 188 //GIT_EXTERN 189 int git_tag_create(libgit2_d.oid.git_oid* oid, libgit2_d.types.git_repository* repo, const (char)* tag_name, const (libgit2_d.types.git_object)* target, const (libgit2_d.types.git_signature)* tagger, const (char)* message, int force); 190 191 /** 192 * Create a new tag in the object database pointing to a git_object 193 * 194 * The message will not be cleaned up. This can be achieved 195 * through `git_message_prettify()`. 196 * 197 * Params: 198 * oid = Pointer where to store the OID of the newly created tag 199 * repo = Repository where to store the tag 200 * tag_name = Name for the tag 201 * target = Object to which this tag points. This object must belong to the given `repo`. 202 * tagger = Signature of the tagger for this tag, and of the tagging time 203 * message = Full message for this tag 204 * 205 * Returns: 0 on success or an error code 206 */ 207 //GIT_EXTERN 208 int git_tag_annotation_create(libgit2_d.oid.git_oid* oid, libgit2_d.types.git_repository* repo, const (char)* tag_name, const (libgit2_d.types.git_object)* target, const (libgit2_d.types.git_signature)* tagger, const (char)* message); 209 210 /** 211 * Create a new tag in the repository from a buffer 212 * 213 * Params: 214 * oid = Pointer where to store the OID of the newly created tag 215 * repo = Repository where to store the tag 216 * buffer = Raw tag data 217 * force = Overwrite existing tags 218 * 219 * Returns: 0 on success; error code otherwise 220 */ 221 //GIT_EXTERN 222 int git_tag_create_from_buffer(libgit2_d.oid.git_oid* oid, libgit2_d.types.git_repository* repo, const (char)* buffer, int force); 223 224 /** 225 * Create a new lightweight tag pointing at a target object 226 * 227 * A new direct reference will be created pointing to 228 * this target object. If `force` is true and a reference 229 * already exists with the given name, it'll be replaced. 230 * 231 * The tag name will be checked for validity. 232 * See `git_tag_create()` for rules about valid names. 233 * 234 * Params: 235 * oid = Pointer where to store the OID of the provided target object. If the tag already exists, this parameter will be filled with the oid of the existing pointed object and the function will return a git_error_code.GIT_EEXISTS error code. 236 * repo = Repository where to store the lightweight tag 237 * tag_name = Name for the tag; this name is validated for consistency. It should also not conflict with an already existing tag name 238 * target = Object to which this tag points. This object must belong to the given `repo`. 239 * force = Overwrite existing references 240 * 241 * Returns: 0 on success, git_error_code.GIT_EINVALIDSPEC or an error code A proper reference is written in the /refs/tags folder, pointing to the provided target object 242 */ 243 //GIT_EXTERN 244 int git_tag_create_lightweight(libgit2_d.oid.git_oid* oid, libgit2_d.types.git_repository* repo, const (char)* tag_name, const (libgit2_d.types.git_object)* target, int force); 245 246 /** 247 * Delete an existing tag reference. 248 * 249 * The tag name will be checked for validity. 250 * See `git_tag_create()` for rules about valid names. 251 * 252 * Params: 253 * repo = Repository where lives the tag 254 * tag_name = Name of the tag to be deleted; this name is validated for consistency. 255 * 256 * Returns: 0 on success, git_error_code.GIT_EINVALIDSPEC or an error code 257 */ 258 //GIT_EXTERN 259 int git_tag_delete(libgit2_d.types.git_repository* repo, const (char)* tag_name); 260 261 /** 262 * Fill a list with all the tags in the Repository 263 * 264 * The string array will be filled with the names of the 265 * matching tags; these values are owned by the user and 266 * should be free'd manually when no longer needed, using 267 * `git_strarray_free`. 268 * 269 * Params: 270 * tag_names = Pointer to a git_strarray structure where the tag names will be stored 271 * repo = Repository where to find the tags 272 * 273 * Returns: 0 or an error code 274 */ 275 //GIT_EXTERN 276 int git_tag_list(libgit2_d.strarray.git_strarray* tag_names, libgit2_d.types.git_repository* repo); 277 278 /** 279 * Fill a list with all the tags in the Repository 280 * which name match a defined pattern 281 * 282 * If an empty pattern is provided, all the tags 283 * will be returned. 284 * 285 * The string array will be filled with the names of the 286 * matching tags; these values are owned by the user and 287 * should be free'd manually when no longer needed, using 288 * `git_strarray_free`. 289 * 290 * Params: 291 * tag_names = Pointer to a git_strarray structure where the tag names will be stored 292 * pattern = Standard fnmatch pattern 293 * repo = Repository where to find the tags 294 * 295 * Returns: 0 or an error code 296 */ 297 //GIT_EXTERN 298 int git_tag_list_match(libgit2_d.strarray.git_strarray* tag_names, const (char)* pattern, libgit2_d.types.git_repository* repo); 299 300 /** 301 * Callback used to iterate over tag names 302 * 303 * @see git_tag_foreach 304 * 305 * Params: 306 * name = The tag name 307 * oid = The tag's OID 308 * payload = Payload passed to git_tag_foreach 309 * 310 * Returns: non-zero to terminate the iteration 311 */ 312 alias git_tag_foreach_cb = int function(const (char)* name, libgit2_d.oid.git_oid* oid, void* payload); 313 314 /** 315 * Call callback `cb' for each tag in the repository 316 * 317 * Params: 318 * repo = Repository 319 * callback = Callback function 320 * payload = Pointer to callback data (optional) 321 */ 322 //GIT_EXTERN 323 int git_tag_foreach(libgit2_d.types.git_repository* repo, .git_tag_foreach_cb callback, void* payload); 324 325 /** 326 * Recursively peel a tag until a non tag git_object is found 327 * 328 * The retrieved `tag_target` object is owned by the repository 329 * and should be closed with the `git_object_free` method. 330 * 331 * Params: 332 * tag_target_out = Pointer to the peeled git_object 333 * tag = The tag to be processed 334 * 335 * Returns: 0 or an error code 336 */ 337 //GIT_EXTERN 338 int git_tag_peel(libgit2_d.types.git_object** tag_target_out, const (libgit2_d.types.git_tag)* tag); 339 340 /** 341 * Create an in-memory copy of a tag. The copy must be explicitly 342 * free'd or it will leak. 343 * 344 * Params: 345 * out_ = Pointer to store the copy of the tag 346 * source = Original tag to copy 347 */ 348 //GIT_EXTERN 349 int git_tag_dup(libgit2_d.types.git_tag** out_, libgit2_d.types.git_tag* source); 350 351 /** @} */