a Æ*Na‚ã@sÊddlmZddlmZddlmZmZmZddlm Z m Z m Z m Z ddl mZgd¢ZGdd „d eƒZGd d „d e e eƒZGd d „d eƒZGdd„de e eƒZGdd„de eƒZGdd„de e eƒZdS)é)Úcli)Ú exceptions)ÚRequiredOptionalÚ RESTManagerÚ RESTObject)Ú CreateMixinÚ ListMixinÚ RefreshMixinÚ RetrieveMixiné)ÚProjectCommitDiscussionManager)Ú ProjectCommitÚProjectCommitManagerÚProjectCommitCommentÚProjectCommitCommentManagerÚProjectCommitStatusÚProjectCommitStatusManagerc@sÒeZdZdZdZe d¡e ej ¡dd„ƒƒZ e dd¡e ej ¡dd„ƒƒZ ejddd e ej ¡dd d „ƒƒZ e d¡e ej ¡d d„ƒƒZe dd¡e ej¡dd„ƒƒZe d¡e ej ¡dd„ƒƒZdS)r Útitle))Úcommentsr)Ú discussionsr )ZstatusesrcKs*d|jj| ¡f}|jjj|fi|¤ŽS)aSGenerate the commit diff. Args: **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabGetError: If the diff could not be retrieved Returns: list: The changes done in this commit z %s/%s/diff©ÚmanagerÚpathÚget_idÚgitlabZhttp_get©ÚselfÚkwargsr©rút/private/var/folders/js/6pj4vh5d4zd0k6bxv74qrbhr0000gr/T/pip-target-22xwyzbs/lib/python/gitlab/v4/objects/commits.pyÚdiffszProjectCommit.diff)ÚbranchcKs:d|jj| ¡f}d|i}|jjj|fd|i|¤ŽdS)aWCherry-pick a commit into a branch. Args: branch (str): Name of target branch **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabCherryPickError: If the cherry-pick could not be performed z%s/%s/cherry_pickr!Ú post_dataN©rrrrZ http_post©rr!rrr"rrrÚ cherry_pick,s zProjectCommit.cherry_pick)Útype)ÚoptionalÚallcKs6d|jj| ¡f}d|i}|jjj|fd|i|¤ŽS)a¿List the references the commit is pushed to. Args: type (str): The scope of references ('branch', 'tag' or 'all') **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabGetError: If the references could not be retrieved Returns: list: The references the commit is pushed to. z %s/%s/refsr&Z query_datar)rr&rrÚdatarrrÚrefs=szProjectCommit.refscKs*d|jj| ¡f}|jjj|fi|¤ŽS)axList the merge requests related to the commit. Args: **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabGetError: If the references could not be retrieved Returns: list: The merge requests related to the commit. z%s/%s/merge_requestsrrrrrÚmerge_requestsQszProjectCommit.merge_requestscKs6d|jj| ¡f}d|i}|jjj|fd|i|¤ŽS)ašRevert a commit on a given branch. Args: branch (str): Name of target branch **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabRevertError: If the revert could not be performed Returns: dict: The new commit data (*not* a RESTObject) z %s/%s/revertr!r"r#r$rrrÚrevertcszProjectCommit.revertcKs*d|jj| ¡f}|jjj|fi|¤ŽS)a[Get the signature of the commit. Args: **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabGetError: If the signature could not be retrieved Returns: dict: The commit's signature data z%s/%s/signaturerrrrrÚ signaturewszProjectCommit.signatureN)r()Ú__name__Ú __module__Ú __qualname__Ú_short_print_attrZ _managersrZregister_custom_actionÚexcÚ on_http_errorZGitlabGetErrorr ZGitlabCherryPickErrorr%r*r+ZGitlabRevertErrorr,r-rrrrr s(             r c@s(eZdZdZeZddiZedddZdS)rz+/projects/%(project_id)s/repository/commitsÚ project_idÚid)r!Zcommit_messageZactions)Ú author_emailZ author_name©Úrequiredr'N) r.r/r0Ú_pathr Ú_obj_clsÚ_from_parent_attrsrÚ _create_attrsrrrrrŠsþrc@seZdZdZdZdS)rNÚnote)r.r/r0Z_id_attrr1rrrrr”src@s*eZdZdZeZdddœZedddZdS) rzB/projects/%(project_id)s/repository/commits/%(commit_id)s/commentsr4r5©r4Ú commit_id)r=)rÚlineÚ line_typer7N) r.r/r0r9rr:r;rr<rrrrr™s  ÿrc@s eZdZdS)rN)r.r/r0rrrrr¢src@s>eZdZdZeZdddœZedddZe   e j ¡dd „ƒZ d S) rzB/projects/%(project_id)s/repository/commits/%(commit_id)s/statusesr4r5r>)Ústate)Ú descriptionÚnameÚcontextÚrefÚ target_urlZcoverager7cKs@d}d|vrd|vr||}n | |¡}tj||fd|i|¤ŽS)aLCreate a new object. Args: data (dict): Parameters to send to the server to create the resource **kwargs: Extra options to send to the server (e.g. sudo or 'ref_name', 'stage', 'name', 'all') Raises: GitlabAuthenticationError: If authentication is not correct GitlabCreateError: If the server cannot perform the request Returns: RESTObject: A new instance of the manage object class build with the data sent by the server z//projects/%(project_id)s/statuses/%(commit_id)sr4r?r)Z _compute_pathrÚcreate)rr)rÚ base_pathrrrrrH¯s   z!ProjectCommitStatusManager.createN) r.r/r0r9rr:r;rr<r2r3ZGitlabCreateErrorrHrrrrr¦s þ rN)rrrr2Z gitlab.baserrrZ gitlab.mixinsrrr r rr Ú__all__r rrrrrrrrrÚs    x