SlHelpers
Loading...
Searching...
No Matches
Tag.h
1// SPDX-License-Identifier: GPL-2.0-only
2
3#pragma once
4
5#include <string>
6
7#include <git2.h>
8#include <variant>
9
10#include "Helpers.h"
11#include "Object.h"
12
13namespace SlGit {
14
15class Blob;
16class Commit;
17class Repo;
18class Tree;
19
23class Tag : public TypedObject<git_tag> {
24 using GitTy = git_tag;
25
26 friend class Repo;
27public:
28 Tag() = delete;
29
31 const git_oid *targetId() const noexcept { return git_tag_target_id(tag()); }
33 std::string targetIdStr() const noexcept { return Helpers::oidToStr(*targetId()); }
35 git_object_t targetType() const noexcept { return git_tag_target_type(tag()); }
36
38 std::string name() const noexcept { return git_tag_name(tag()); }
40 const git_signature *tagger() const noexcept { return git_tag_tagger(tag()); }
42 std::string message() const noexcept { return git_tag_message(tag()); }
43
45 std::variant<std::monostate, Commit, Tree, Blob> peel() const noexcept;
46
48 GitTy *tag() const noexcept { return typed(); }
49private:
50 explicit Tag(const Repo &repo, GitTy *tag) noexcept;
51};
52
53}
Blob is a representation of a git blob.
Definition Blob.h:16
Commit is a representation of a git commit.
Definition Commit.h:21
static std::string oidToStr(const git_oid &id)
Convert OID id to string.
Definition Helpers.h:20
const Repo & repo() const
Get the Repo this Object lives in.
Definition Object.h:38
The most important Git class.
Definition Repo.h:45
Tag is a representation of a git tag.
Definition Tag.h:23
GitTy * tag() const noexcept
Get the stored pointer to libgit2's git_tag.
Definition Tag.h:48
const git_oid * targetId() const noexcept
Get the OID of the target of this Tag.
Definition Tag.h:31
const git_signature * tagger() const noexcept
Get the tagger of this Tag.
Definition Tag.h:40
std::string targetIdStr() const noexcept
Get the SHA of the target of this Tag.
Definition Tag.h:33
std::variant< std::monostate, Commit, Tree, Blob > peel() const noexcept
Peel this Tag until the underlaying object is found and return that.
std::string name() const noexcept
Get the name of this Tag (the tag proper).
Definition Tag.h:38
std::string message() const noexcept
Get the tag message of this Tag.
Definition Tag.h:42
git_object_t targetType() const noexcept
Get the type of the target of this Tag (GIT_OBJECT_COMMIT, ...).
Definition Tag.h:35
Tree is a representation of a git tree.
Definition Tree.h:27
git_tag * typed() const noexcept
Definition Object.h:83