| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 51718ea commit 096d9ec
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -103,6 +103,10 @@ Create/delete a fork relation between projects (requires admin permissions):: | |||
| 103 | 103 | project.create_fork_relation(source_project.id) | |
| 104 | 104 | project.delete_fork_relation() | |
| 105 | 105 | ||
| 106 | + Get languages used in the project with percentage value:: | ||
| 107 | + | ||
| 108 | + languages = project.languages() | ||
| 109 | + | ||
| 106 | 110 | Star/unstar a project:: | |
| 107 | 111 | ||
| 108 | 112 | project.star() | |
@@ -157,6 +161,15 @@ Get the content of a file using the blob id:: | |||
| 157 | 161 | Blobs are entirely stored in memory unless you use the streaming feature. | |
| 158 | 162 | See :ref:`the artifacts example <streaming_example>`. | |
| 159 | 163 | ||
| 164 | + Get a snapshot of the repository:: | ||
| 165 | + | ||
| 166 | + tar_file = project.snapshot() | ||
| 167 | + | ||
| 168 | + .. warning:: | ||
| 169 | + | ||
| 170 | + Snapshots are entirely stored in memory unless you use the streaming | ||
| 171 | + feature. See :ref:`the artifacts example <streaming_example>`. | ||
| 172 | + | ||
| 160 | 173 | Compare two branches, tags or commits:: | |
| 161 | 174 | ||
| 162 | 175 | result = project.repository_compare('master', 'branch1') | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -118,4 +118,11 @@ def test_parser(self): | |||
| 118 | 118 | ||
| 119 | 119 | actions = user_subparsers.choices['create']._option_string_actions | |
| 120 | 120 | self.assertFalse(actions['--description'].required) | |
| 121 | + | ||
| 122 | + user_subparsers = None | ||
| 123 | + for action in subparsers.choices['group']._actions: | ||
| 124 | + if type(action) == argparse._SubParsersAction: | ||
| 125 | + user_subparsers = action | ||
| 126 | + break | ||
| 127 | + actions = user_subparsers.choices['create']._option_string_actions | ||
| 121 | 128 | self.assertTrue(actions['--name'].required) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1380,6 +1380,10 @@ class ProjectForkManager(CreateMixin, RESTManager): | |||
| 1380 | 1380 | _path = '/projects/%(project_id)s/fork' | |
| 1381 | 1381 | _obj_cls = ProjectFork | |
| 1382 | 1382 | _from_parent_attrs = {'project_id': 'id'} | |
| 1383 | + _list_filters = ('archived', 'visibility', 'order_by', 'sort', 'search', | ||
| 1384 | + 'simple', 'owned', 'membership', 'starred', 'statistics', | ||
| 1385 | + 'with_custom_attributes', 'with_issues_enabled', | ||
| 1386 | + 'with_merge_requests_enabled') | ||
| 1383 | 1387 | _create_attrs = (tuple(), ('namespace', )) | |
| 1384 | 1388 | ||
| 1385 | 1389 | ||
@@ -1393,15 +1397,17 @@ class ProjectHookManager(CRUDMixin, RESTManager): | |||
| 1393 | 1397 | _from_parent_attrs = {'project_id': 'id'} | |
| 1394 | 1398 | _create_attrs = ( | |
| 1395 | 1399 | ('url', ), | |
| 1396 | - ('push_events', 'issues_events', 'note_events', | ||
| 1397 | - 'merge_requests_events', 'tag_push_events', 'build_events', | ||
| 1398 | - 'enable_ssl_verification', 'token', 'pipeline_events') | ||
| 1400 | + ('push_events', 'issues_events', 'confidential_issues_events', | ||
| 1401 | + 'merge_requests_events', 'tag_push_events', 'note_events', | ||
| 1402 | + 'job_events', 'pipeline_events', 'wiki_page_events', | ||
| 1403 | + 'enable_ssl_verification', 'token') | ||
| 1399 | 1404 | ) | |
| 1400 | 1405 | _update_attrs = ( | |
| 1401 | 1406 | ('url', ), | |
| 1402 | - ('push_events', 'issues_events', 'note_events', | ||
| 1403 | - 'merge_requests_events', 'tag_push_events', 'build_events', | ||
| 1404 | - 'enable_ssl_verification', 'token', 'pipeline_events') | ||
| 1407 | + ('push_events', 'issues_events', 'confidential_issues_events', | ||
| 1408 | + 'merge_requests_events', 'tag_push_events', 'note_events', | ||
| 1409 | + 'job_events', 'pipeline_events', 'wiki_events', | ||
| 1410 | + 'enable_ssl_verification', 'token') | ||
| 1405 | 1411 | ) | |
| 1406 | 1412 | ||
| 1407 | 1413 | ||
@@ -2906,6 +2912,21 @@ def delete_merged_branches(self, **kwargs): | |||
| 2906 | 2912 | path = '/projects/%s/repository/merged_branches' % self.get_id() | |
| 2907 | 2913 | self.manager.gitlab.http_delete(path, **kwargs) | |
| 2908 | 2914 | ||
| 2915 | + @cli.register_custom_action('Project') | ||
| 2916 | + @exc.on_http_error(exc.GitlabGetError) | ||
| 2917 | + def languages(self, **kwargs): | ||
| 2918 | + """Get languages used in the project with percentage value. | ||
| 2919 | + | ||
| 2920 | + Args: | ||
| 2921 | + **kwargs: Extra options to send to the server (e.g. sudo) | ||
| 2922 | + | ||
| 2923 | + Raises: | ||
| 2924 | + GitlabAuthenticationError: If authentication is not correct | ||
| 2925 | + GitlabGetError: If the server failed to perform the request | ||
| 2926 | + """ | ||
| 2927 | + path = '/projects/%s/languages' % self.get_id() | ||
| 2928 | + return self.manager.gitlab.http_get(path, **kwargs) | ||
| 2929 | + | ||
| 2909 | 2930 | @cli.register_custom_action('Project') | |
| 2910 | 2931 | @exc.on_http_error(exc.GitlabCreateError) | |
| 2911 | 2932 | def star(self, **kwargs): | |
@@ -3100,6 +3121,34 @@ def upload(self, filename, filedata=None, filepath=None, **kwargs): | |||
| 3100 | 3121 | "markdown": data['markdown'] | |
| 3101 | 3122 | } | |
| 3102 | 3123 | ||
| 3124 | + @cli.register_custom_action('Project', optional=('wiki',)) | ||
| 3125 | + @exc.on_http_error(exc.GitlabGetError) | ||
| 3126 | + def snapshot(self, wiki=False, streamed=False, action=None, | ||
| 3127 | + chunk_size=1024, **kwargs): | ||
| 3128 | + """Return a snapshot of the repository. | ||
| 3129 | + | ||
| 3130 | + Args: | ||
| 3131 | + wiki (bool): If True return the wiki repository | ||
| 3132 | + streamed (bool): If True the data will be processed by chunks of | ||
| 3133 | + `chunk_size` and each chunk is passed to `action` for | ||
| 3134 | + treatment. | ||
| 3135 | + action (callable): Callable responsible of dealing with chunk of | ||
| 3136 | + data | ||
| 3137 | + chunk_size (int): Size of each chunk | ||
| 3138 | + **kwargs: Extra options to send to the server (e.g. sudo) | ||
| 3139 | + | ||
| 3140 | + Raises: | ||
| 3141 | + GitlabAuthenticationError: If authentication is not correct | ||
| 3142 | + GitlabGetError: If the content could not be retrieved | ||
| 3143 | + | ||
| 3144 | + Returns: | ||
| 3145 | + str: The uncompressed tar archive of the repository | ||
| 3146 | + """ | ||
| 3147 | + path = '/projects/%d/snapshot' % self.get_id() | ||
| 3148 | + result = self.manager.gitlab.http_get(path, streamed=streamed, | ||
| 3149 | + **kwargs) | ||
| 3150 | + return utils.response_content(result, streamed, action, chunk_size) | ||
| 3151 | + | ||
| 3103 | 3152 | @cli.register_custom_action('Project', ('scope', 'search')) | |
| 3104 | 3153 | @exc.on_http_error(exc.GitlabSearchError) | |
| 3105 | 3154 | def search(self, scope, search, **kwargs): | |
@@ -3126,29 +3175,31 @@ class ProjectManager(CRUDMixin, RESTManager): | |||
| 3126 | 3175 | _path = '/projects' | |
| 3127 | 3176 | _obj_cls = Project | |
| 3128 | 3177 | _create_attrs = ( | |
| 3129 | - ('name', ), | ||
| 3130 | - ('path', 'namespace_id', 'description', 'issues_enabled', | ||
| 3178 | + tuple(), | ||
| 3179 | + ('name', 'path', 'namespace_id', 'description', 'issues_enabled', | ||
| 3131 | 3180 | 'merge_requests_enabled', 'jobs_enabled', 'wiki_enabled', | |
| 3132 | - 'snippets_enabled', 'container_registry_enabled', | ||
| 3133 | - 'shared_runners_enabled', 'visibility', 'import_url', 'public_jobs', | ||
| 3134 | - 'only_allow_merge_if_build_succeeds', | ||
| 3135 | - 'only_allow_merge_if_all_discussions_are_resolved', 'lfs_enabled', | ||
| 3136 | - 'request_access_enabled', 'printing_merge_request_link_enabled') | ||
| 3181 | + 'snippets_enabled', 'resolve_outdated_diff_discussions', | ||
| 3182 | + 'container_registry_enabled', 'shared_runners_enabled', 'visibility', | ||
| 3183 | + 'import_url', 'public_jobs', 'only_allow_merge_if_pipeline_succeeds', | ||
| 3184 | + 'only_allow_merge_if_all_discussions_are_resolved', 'merge_method', | ||
| 3185 | + 'lfs_enabled', 'request_access_enabled', 'tag_list', 'avatar', | ||
| 3186 | + 'printing_merge_request_link_enabled', 'ci_config_path') | ||
| 3137 | 3187 | ) | |
| 3138 | 3188 | _update_attrs = ( | |
| 3139 | 3189 | tuple(), | |
| 3140 | 3190 | ('name', 'path', 'default_branch', 'description', 'issues_enabled', | |
| 3141 | 3191 | 'merge_requests_enabled', 'jobs_enabled', 'wiki_enabled', | |
| 3142 | - 'snippets_enabled', 'container_registry_enabled', | ||
| 3143 | - 'shared_runners_enabled', 'visibility', 'import_url', 'public_jobs', | ||
| 3144 | - 'only_allow_merge_if_build_succeeds', | ||
| 3145 | - 'only_allow_merge_if_all_discussions_are_resolved', 'lfs_enabled', | ||
| 3146 | - 'request_access_enabled', 'printing_merge_request_link_enabled') | ||
| 3192 | + 'snippets_enabled', 'resolve_outdated_diff_discussions', | ||
| 3193 | + 'container_registry_enabled', 'shared_runners_enabled', 'visibility', | ||
| 3194 | + 'import_url', 'public_jobs', 'only_allow_merge_if_pipeline_succeeds', | ||
| 3195 | + 'only_allow_merge_if_all_discussions_are_resolved', 'merge_method', | ||
| 3196 | + 'lfs_enabled', 'request_access_enabled', 'tag_list', 'avatar', | ||
| 3197 | + 'ci_config_path') | ||
| 3147 | 3198 | ) | |
| 3148 | 3199 | _list_filters = ('search', 'owned', 'starred', 'archived', 'visibility', | |
| 3149 | 3200 | 'order_by', 'sort', 'simple', 'membership', 'statistics', | |
| 3150 | 3201 | 'with_issues_enabled', 'with_merge_requests_enabled', | |
| 3151 | - 'custom_attributes') | ||
| 3202 | + 'with_custom_attributes') | ||
| 3152 | 3203 | ||
| 3153 | 3204 | def import_project(self, file, path, namespace=None, overwrite=False, | |
| 3154 | 3205 | override_params=None, **kwargs): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -413,6 +413,7 @@ | |||
| 413 | 413 | archive1 = admin_project.repository_archive() | |
| 414 | 414 | archive2 = admin_project.repository_archive('master') | |
| 415 | 415 | assert(archive1 == archive2) | |
| 416 | + snapshot = admin_project.snapshot() | ||
| 416 | 417 | ||
| 417 | 418 | # project file uploads | |
| 418 | 419 | filename = "test.txt" | |
| Back | FazBrowse Home | New Git URL |
0 commit comments