| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -161,6 +161,10 @@ class GitlabMRForbiddenError(GitlabOperationError): | |||
| 161 | 161 | pass | |
| 162 | 162 | ||
| 163 | 163 | ||
| 164 | + class GitlabMRApprovalError(GitlabOperationError): | ||
| 165 | + pass | ||
| 166 | + | ||
| 167 | + | ||
| 164 | 168 | class GitlabMRClosedError(GitlabOperationError): | |
| 165 | 169 | pass | |
| 166 | 170 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2132,6 +2132,47 @@ def changes(self, **kwargs): | |||
| 2132 | 2132 | path = '%s/%s/changes' % (self.manager.path, self.get_id()) | |
| 2133 | 2133 | return self.manager.gitlab.http_get(path, **kwargs) | |
| 2134 | 2134 | ||
| 2135 | + @cli.register_custom_action('ProjectMergeRequest', tuple(), ('sha')) | ||
| 2136 | + @exc.on_http_error(exc.GitlabMRApprovalError) | ||
| 2137 | + def approve(self, sha=None, **kwargs): | ||
| 2138 | + """Approve the merge request. | ||
| 2139 | + | ||
| 2140 | + Args: | ||
| 2141 | + sha (str): Head SHA of MR | ||
| 2142 | + **kwargs: Extra options to send to the server (e.g. sudo) | ||
| 2143 | + | ||
| 2144 | + Raises: | ||
| 2145 | + GitlabAuthenticationError: If authentication is not correct | ||
| 2146 | + GitlabMRApprovalError: If the approval failed | ||
| 2147 | + """ | ||
| 2148 | + path = '%s/%s/approve' % (self.manager.path, self.get_id()) | ||
| 2149 | + data = {} | ||
| 2150 | + if sha: | ||
| 2151 | + data['sha'] = sha | ||
| 2152 | + | ||
| 2153 | + server_data = self.manager.gitlab.http_post(path, post_data=data, | ||
| 2154 | + **kwargs) | ||
| 2155 | + self._update_attrs(server_data) | ||
| 2156 | + | ||
| 2157 | + @cli.register_custom_action('ProjectMergeRequest') | ||
| 2158 | + @exc.on_http_error(exc.GitlabMRApprovalError) | ||
| 2159 | + def unapprove(self, **kwargs): | ||
| 2160 | + """Unapprove the merge request. | ||
| 2161 | + | ||
| 2162 | + Args: | ||
| 2163 | + **kwargs: Extra options to send to the server (e.g. sudo) | ||
| 2164 | + | ||
| 2165 | + Raises: | ||
| 2166 | + GitlabAuthenticationError: If authentication is not correct | ||
| 2167 | + GitlabMRApprovalError: If the unapproval failed | ||
| 2168 | + """ | ||
| 2169 | + path = '%s/%s/unapprove' % (self.manager.path, self.get_id()) | ||
| 2170 | + data = {} | ||
| 2171 | + | ||
| 2172 | + server_data = self.manager.gitlab.http_post(path, post_data=data, | ||
| 2173 | + **kwargs) | ||
| 2174 | + self._update_attrs(server_data) | ||
| 2175 | + | ||
| 2135 | 2176 | @cli.register_custom_action('ProjectMergeRequest', tuple(), | |
| 2136 | 2177 | ('merge_commit_message', | |
| 2137 | 2178 | 'should_remove_source_branch', | |
| Back | FazBrowse Home | New Git URL |
0 commit comments