3 @qhc@sddlmZddlmZddlmZmZmZddlm Z m Z m Z m Z ddl mZddd d d d gZGd ddeZGddde e eZGdd d eZGdd d e e eZGdd d e eZGdd d e e eZdS))cli) exceptions)RequiredOptional RESTManager RESTObject) CreateMixin ListMixin RefreshMixin RetrieveMixin)ProjectCommitDiscussionManager ProjectCommitProjectCommitManagerProjectCommitCommentProjectCommitCommentManagerProjectCommitStatusProjectCommitStatusManagerc@seZdZdZdZejdejej dd Z ejddejej d d Z ejdddejej dddZ ejdejej ddZejdd ejejddZejdejej ddZdS)!r titlecommentsr discussionsr statusesrcKs&d|jj|jf}|jjj|f|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)managerpathget_idgitlabhttp_get)selfkwargsrrX/home/ec2-user/environment/venv/lib/python3.6/dist-packages/gitlab/v4/objects/commits.pydiffszProjectCommit.diffbranchcKs:d|jj|jf}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)rrrr http_post)rr!rrr"rrr cherry_pick,s zProjectCommit.cherry_picktype)optionalallcKs6d|jj|jf}d|i}|jjj|fd|i|S)aList 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_data)rrrrr)rr%rrdatarrrrefs=szProjectCommit.refscKs&d|jj|jf}|jjj|f|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_requests)rrrrr)rrrrrrmerge_requestsQszProjectCommit.merge_requestscKs6d|jj|jf}d|i}|jjj|fd|i|S)aRevert 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")rrrrr#)rr!rrr"rrrrevertcszProjectCommit.revertcKs&d|jj|jf}|jjj|f|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/signature)rrrrr)rrrrrr signaturewszProjectCommit.signatureNrrrr rr)r-r.r/)r!)r%)r')r!)__name__ __module__ __qualname___short_print_attrZ _managersrZregister_custom_actionexc on_http_errorZGitlabGetErrorr ZGitlabCherryPickErrorr$r)r*ZGitlabRevertErrorr+r,rrrrr s"    c@s(eZdZdZeZddiZed d d Zd S) rz+/projects/%(project_id)s/repository/commits project_ididr!commit_messageactions author_email author_name)requiredr&N)r!r8r9)r:r;) r0r1r2_pathr _obj_cls_from_parent_attrsr _create_attrsrrrrrs c@seZdZdZdZdS)rNnote)r0r1r2Z_id_attrr3rrrrrsc@s*eZdZdZeZdddZed d d Zd S) rzB/projects/%(project_id)s/repository/commits/%(commit_id)s/commentsr6r7)r6 commit_idrArline line_type)r<r&N)rA)rrCrD) r0r1r2r=rr>r?rr@rrrrrs  c@s eZdZdS)rN)r0r1r2rrrrrsc@s>eZdZdZeZdddZeddd Ze j e j d dZ dS)rzB/projects/%(project_id)s/repository/commits/%(commit_id)s/statusesr6r7)r6rBstate descriptionnamecontextref target_urlcoverage)r<r&cKs@d}d|krd|kr||}n |j|}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)sr6rBr)Z _compute_pathrcreate)rr(r base_pathrrrrrLs   z!ProjectCommitStatusManager.createN)rE)rFrGrHrIrJrK) r0r1r2r=rr>r?rr@r4r5ZGitlabCreateErrorrLrrrrrs N)rrrr4Z gitlab.baserrrZ gitlab.mixinsrrr r rr __all__r rrrrrrrrrs   x