GitTag.py
1 ############################ Copyrights and license ############################ 2 # # 3 # Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> # 4 # Copyright 2012 Zearin <zearin@gonk.net> # 5 # Copyright 2013 AKFish <akfish@gmail.com> # 6 # Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> # 7 # Copyright 2014 Vincent Jacques <vincent@vincent-jacques.net> # 8 # Copyright 2016 Jannis Gebauer <ja.geb@me.com> # 9 # Copyright 2016 Peter Buckley <dx-pbuckley@users.noreply.github.com> # 10 # Copyright 2018 Wan Liuyang <tsfdye@gmail.com> # 11 # Copyright 2018 sfdye <tsfdye@gmail.com> # 12 # # 13 # This file is part of PyGithub. # 14 # http://pygithub.readthedocs.io/ # 15 # # 16 # PyGithub is free software: you can redistribute it and/or modify it under # 17 # the terms of the GNU Lesser General Public License as published by the Free # 18 # Software Foundation, either version 3 of the License, or (at your option) # 19 # any later version. # 20 # # 21 # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # 22 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # 23 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # 24 # details. # 25 # # 26 # You should have received a copy of the GNU Lesser General Public License # 27 # along with PyGithub. If not, see <http://www.gnu.org/licenses/>. # 28 # # 29 ################################################################################ 30 31 from __future__ import annotations 32 33 from typing import TYPE_CHECKING, Any 34 35 import github.GitAuthor 36 import github.GithubObject 37 import github.GitObject 38 import github.GitTreeElement 39 from github.GithubObject import Attribute, CompletableGithubObject, NotSet 40 41 if TYPE_CHECKING: 42 from github.GitAuthor import GitAuthor 43 from github.GitObject import GitObject 44 45 46 class GitTag(CompletableGithubObject): 47 """ 48 This class represents GitTags. The reference can be found here https://docs.github.com/en/rest/reference/git#tags 49 """ 50 51 def _initAttributes(self) -> None: 52 self._message: Attribute[str] = NotSet 53 self._object: Attribute[GitObject] = NotSet 54 self._sha: Attribute[str] = NotSet 55 self._tag: Attribute[str] = NotSet 56 self._tagger: Attribute[GitAuthor] = NotSet 57 self._url: Attribute[str] = NotSet 58 59 def __repr__(self) -> str: 60 return self.get__repr__({"sha": self._sha.value, "tag": self._tag.value}) 61 62 @property 63 def message(self) -> str: 64 self._completeIfNotSet(self._message) 65 return self._message.value 66 67 @property 68 def object(self) -> GitObject: 69 self._completeIfNotSet(self._object) 70 return self._object.value 71 72 @property 73 def sha(self) -> str: 74 self._completeIfNotSet(self._sha) 75 return self._sha.value 76 77 @property 78 def tag(self) -> str: 79 self._completeIfNotSet(self._tag) 80 return self._tag.value 81 82 @property 83 def tagger(self) -> GitAuthor: 84 self._completeIfNotSet(self._tagger) 85 return self._tagger.value 86 87 @property 88 def url(self) -> str: 89 self._completeIfNotSet(self._url) 90 return self._url.value 91 92 def _useAttributes(self, attributes: dict[str, Any]) -> None: 93 if "message" in attributes: # pragma no branch 94 self._message = self._makeStringAttribute(attributes["message"]) 95 if "object" in attributes: # pragma no branch 96 self._object = self._makeClassAttribute(github.GitObject.GitObject, attributes["object"]) 97 if "sha" in attributes: # pragma no branch 98 self._sha = self._makeStringAttribute(attributes["sha"]) 99 if "tag" in attributes: # pragma no branch 100 self._tag = self._makeStringAttribute(attributes["tag"]) 101 if "tagger" in attributes: # pragma no branch 102 self._tagger = self._makeClassAttribute(github.GitAuthor.GitAuthor, attributes["tagger"]) 103 if "url" in attributes: # pragma no branch 104 self._url = self._makeStringAttribute(attributes["url"])