gitlab-projects-settings 4.0.0__tar.gz → 4.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/CHANGELOG.md +10 -0
  2. {gitlab_projects_settings-4.0.0/gitlab_projects_settings.egg-info → gitlab_projects_settings-4.1.0}/PKG-INFO +14 -3
  3. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/README.md +12 -2
  4. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0/gitlab_projects_settings.egg-info}/PKG-INFO +14 -3
  5. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/gitlab_projects_settings.egg-info/SOURCES.txt +1 -0
  6. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/gitlab_projects_settings.egg-info/requires.txt +1 -0
  7. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/requirements/runtime.txt +1 -0
  8. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/src/cli/entrypoint.py +42 -2
  9. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/src/cli/main.py +6 -2
  10. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/src/features/gitlab.py +5 -5
  11. gitlab_projects_settings-4.1.0/src/prints/themes.py +60 -0
  12. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/src/types/gitlab.py +22 -0
  13. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/.chglog/CHANGELOG.tpl.md +0 -0
  14. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/.chglog/changelog.sh +0 -0
  15. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/.chglog/config.yml +0 -0
  16. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/.gitignore +0 -0
  17. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/.gitlab-ci.yml +0 -0
  18. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/.markdownlint.json +0 -0
  19. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/.style.yapf +0 -0
  20. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/.vscode/extensions.json +0 -0
  21. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/.vscode/settings.json +0 -0
  22. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/LICENSE +0 -0
  23. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/gitlab_projects_settings.egg-info/dependency_links.txt +0 -0
  24. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/gitlab_projects_settings.egg-info/entry_points.txt +0 -0
  25. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/gitlab_projects_settings.egg-info/top_level.txt +0 -0
  26. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/mypy.ini +0 -0
  27. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/requirements/build.txt +0 -0
  28. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/requirements/deploy.txt +0 -0
  29. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/requirements/quality.txt +0 -0
  30. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/setup.cfg +0 -0
  31. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/setup.py +0 -0
  32. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/src/__init__.py +0 -0
  33. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/src/__main__.py +0 -0
  34. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/src/cli/__init__.py +0 -0
  35. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/src/features/__init__.py +0 -0
  36. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/src/package/__init__.py +0 -0
  37. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/src/package/bundle.py +0 -0
  38. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/src/package/settings.py +0 -0
  39. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/src/package/updates.py +0 -0
  40. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/src/package/version.py +0 -0
  41. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/src/prints/__init__.py +0 -0
  42. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/src/prints/boxes.py +0 -0
  43. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/src/prints/colors.py +0 -0
  44. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/src/system/__init__.py +0 -0
  45. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/src/system/platform.py +0 -0
  46. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/src/types/__init__.py +0 -0
  47. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/src/types/namespaces.py +0 -0
  48. {gitlab_projects_settings-4.0.0 → gitlab_projects_settings-4.1.0}/src/types/strings.py +0 -0
@@ -1,4 +1,14 @@
1
1
 
2
+ <a name="4.1.0"></a>
3
+ ## [4.1.0](https://gitlab.com/AdrianDC/gitlab-projects-settings/compare/4.0.0...4.1.0) (2024-05-17)
4
+
5
+ ### Features
6
+
7
+ * **entrypoint:** implement prompt confirmation upon deletions
8
+ * **gitlab:** isolate 'ProtectionLevels' enumeration
9
+ * **requirements:** prepare 'questionary' library integration
10
+
11
+
2
12
  <a name="4.0.0"></a>
3
13
  ## [4.0.0](https://gitlab.com/AdrianDC/gitlab-projects-settings/compare/3.0.0...4.0.0) (2024-05-15)
4
14
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gitlab-projects-settings
3
- Version: 4.0.0
3
+ Version: 4.1.0
4
4
  Summary: Configure GitLab groups and projects settings automatically
5
5
  Home-page: https://gitlab.com/AdrianDC/gitlab-projects-settings
6
6
  Author: Adrian DC
@@ -30,6 +30,7 @@ Description-Content-Type: text/markdown
30
30
  License-File: LICENSE
31
31
  Requires-Dist: colored>=1.4.2
32
32
  Requires-Dist: python-gitlab>=4.4.0
33
+ Requires-Dist: questionary>=2.0.1
33
34
  Requires-Dist: setuptools>=45.1.0
34
35
  Requires-Dist: update_checker>=0.18.0
35
36
 
@@ -69,7 +70,7 @@ usage: gitlab-projects-settings [-h] [--version] [--update-check] [--settings] [
69
70
  [--disable-features FEATURES] [--enable-features FEATURES] [--reset-members]
70
71
  [--set-avatar FILE] [--set-description TEXT] [--update-description]
71
72
  [--run-housekeeping] [--archive-project | --unarchive-project] [--delete-group]
72
- [--delete-project] [--protect-branches] [--protect-tags LEVEL] [--]
73
+ [--delete-project] [--protect-branches] [--protect-tags [LEVEL]] [--]
73
74
  [gitlab] [path]
74
75
 
75
76
  gitlab-projects-settings: Configure GitLab groups and projects settings automatically
@@ -111,7 +112,7 @@ advanced settings arguments:
111
112
 
112
113
  repository settings arguments:
113
114
  --protect-branches # Protect branches with default master/main, develop and staging
114
- --protect-tags LEVEL # Protect tags at level [no-one,admins,maintainers,developers]
115
+ --protect-tags [LEVEL] # Protect tags at level [no-one,admins,maintainers,developers] (default: no-one)
115
116
 
116
117
  positional arguments:
117
118
  -- # Positional arguments separator (recommended)
@@ -138,10 +139,20 @@ gitlab-projects-settings --settings
138
139
 
139
140
  ---
140
141
 
142
+ ## Environment available configurations
143
+
144
+ `gitlab-projects-settings` uses `colored` for colors outputs and `questionary` for interactive menus.
145
+
146
+ If colors of both outputs types do not match the terminal's theme,
147
+ an environment variable `NO_COLOR=1` can be defined to disable colors.
148
+
149
+ ---
150
+
141
151
  ## Dependencies
142
152
 
143
153
  - [colored](https://pypi.org/project/colored/): Terminal colors and styles
144
154
  - [python-gitlab](https://pypi.org/project/python-gitlab/): A python wrapper for the GitLab API
155
+ - [questionary](https://pypi.org/project/questionary/): Interactive terminal user interfaces
145
156
  - [setuptools](https://pypi.org/project/setuptools/): Build and manage Python packages
146
157
  - [update-checker](https://pypi.org/project/update-checker/): Check for package updates on PyPI
147
158
 
@@ -34,7 +34,7 @@ usage: gitlab-projects-settings [-h] [--version] [--update-check] [--settings] [
34
34
  [--disable-features FEATURES] [--enable-features FEATURES] [--reset-members]
35
35
  [--set-avatar FILE] [--set-description TEXT] [--update-description]
36
36
  [--run-housekeeping] [--archive-project | --unarchive-project] [--delete-group]
37
- [--delete-project] [--protect-branches] [--protect-tags LEVEL] [--]
37
+ [--delete-project] [--protect-branches] [--protect-tags [LEVEL]] [--]
38
38
  [gitlab] [path]
39
39
 
40
40
  gitlab-projects-settings: Configure GitLab groups and projects settings automatically
@@ -76,7 +76,7 @@ advanced settings arguments:
76
76
 
77
77
  repository settings arguments:
78
78
  --protect-branches # Protect branches with default master/main, develop and staging
79
- --protect-tags LEVEL # Protect tags at level [no-one,admins,maintainers,developers]
79
+ --protect-tags [LEVEL] # Protect tags at level [no-one,admins,maintainers,developers] (default: no-one)
80
80
 
81
81
  positional arguments:
82
82
  -- # Positional arguments separator (recommended)
@@ -103,10 +103,20 @@ gitlab-projects-settings --settings
103
103
 
104
104
  ---
105
105
 
106
+ ## Environment available configurations
107
+
108
+ `gitlab-projects-settings` uses `colored` for colors outputs and `questionary` for interactive menus.
109
+
110
+ If colors of both outputs types do not match the terminal's theme,
111
+ an environment variable `NO_COLOR=1` can be defined to disable colors.
112
+
113
+ ---
114
+
106
115
  ## Dependencies
107
116
 
108
117
  - [colored](https://pypi.org/project/colored/): Terminal colors and styles
109
118
  - [python-gitlab](https://pypi.org/project/python-gitlab/): A python wrapper for the GitLab API
119
+ - [questionary](https://pypi.org/project/questionary/): Interactive terminal user interfaces
110
120
  - [setuptools](https://pypi.org/project/setuptools/): Build and manage Python packages
111
121
  - [update-checker](https://pypi.org/project/update-checker/): Check for package updates on PyPI
112
122
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gitlab-projects-settings
3
- Version: 4.0.0
3
+ Version: 4.1.0
4
4
  Summary: Configure GitLab groups and projects settings automatically
5
5
  Home-page: https://gitlab.com/AdrianDC/gitlab-projects-settings
6
6
  Author: Adrian DC
@@ -30,6 +30,7 @@ Description-Content-Type: text/markdown
30
30
  License-File: LICENSE
31
31
  Requires-Dist: colored>=1.4.2
32
32
  Requires-Dist: python-gitlab>=4.4.0
33
+ Requires-Dist: questionary>=2.0.1
33
34
  Requires-Dist: setuptools>=45.1.0
34
35
  Requires-Dist: update_checker>=0.18.0
35
36
 
@@ -69,7 +70,7 @@ usage: gitlab-projects-settings [-h] [--version] [--update-check] [--settings] [
69
70
  [--disable-features FEATURES] [--enable-features FEATURES] [--reset-members]
70
71
  [--set-avatar FILE] [--set-description TEXT] [--update-description]
71
72
  [--run-housekeeping] [--archive-project | --unarchive-project] [--delete-group]
72
- [--delete-project] [--protect-branches] [--protect-tags LEVEL] [--]
73
+ [--delete-project] [--protect-branches] [--protect-tags [LEVEL]] [--]
73
74
  [gitlab] [path]
74
75
 
75
76
  gitlab-projects-settings: Configure GitLab groups and projects settings automatically
@@ -111,7 +112,7 @@ advanced settings arguments:
111
112
 
112
113
  repository settings arguments:
113
114
  --protect-branches # Protect branches with default master/main, develop and staging
114
- --protect-tags LEVEL # Protect tags at level [no-one,admins,maintainers,developers]
115
+ --protect-tags [LEVEL] # Protect tags at level [no-one,admins,maintainers,developers] (default: no-one)
115
116
 
116
117
  positional arguments:
117
118
  -- # Positional arguments separator (recommended)
@@ -138,10 +139,20 @@ gitlab-projects-settings --settings
138
139
 
139
140
  ---
140
141
 
142
+ ## Environment available configurations
143
+
144
+ `gitlab-projects-settings` uses `colored` for colors outputs and `questionary` for interactive menus.
145
+
146
+ If colors of both outputs types do not match the terminal's theme,
147
+ an environment variable `NO_COLOR=1` can be defined to disable colors.
148
+
149
+ ---
150
+
141
151
  ## Dependencies
142
152
 
143
153
  - [colored](https://pypi.org/project/colored/): Terminal colors and styles
144
154
  - [python-gitlab](https://pypi.org/project/python-gitlab/): A python wrapper for the GitLab API
155
+ - [questionary](https://pypi.org/project/questionary/): Interactive terminal user interfaces
145
156
  - [setuptools](https://pypi.org/project/setuptools/): Build and manage Python packages
146
157
  - [update-checker](https://pypi.org/project/update-checker/): Check for package updates on PyPI
147
158
 
@@ -37,6 +37,7 @@ src/package/version.py
37
37
  src/prints/__init__.py
38
38
  src/prints/boxes.py
39
39
  src/prints/colors.py
40
+ src/prints/themes.py
40
41
  src/system/__init__.py
41
42
  src/system/platform.py
42
43
  src/types/__init__.py
@@ -1,4 +1,5 @@
1
1
  colored>=1.4.2
2
2
  python-gitlab>=4.4.0
3
+ questionary>=2.0.1
3
4
  setuptools>=45.1.0
4
5
  update_checker>=0.18.0
@@ -1,4 +1,5 @@
1
1
  colored>=1.4.2
2
2
  python-gitlab>=4.4.0
3
+ questionary>=2.0.1
3
4
  setuptools>=45.1.0
4
5
  update_checker>=0.18.0
@@ -12,10 +12,12 @@ from gitlab.v4.objects import (
12
12
  Project as GitLabProject,
13
13
  User as GitLabUser,
14
14
  )
15
+ import questionary
15
16
 
16
17
  # Components
17
18
  from ..features.gitlab import GitLabFeature
18
19
  from ..prints.colors import Colors
20
+ from ..prints.themes import Themes
19
21
  from ..system.platform import Platform
20
22
  from ..types.namespaces import Namespaces
21
23
 
@@ -173,6 +175,30 @@ class Entrypoint:
173
175
  # Result
174
176
  return Entrypoint.Result.SUCCESS
175
177
 
178
+ # Confirm
179
+ @staticmethod
180
+ def confirm(description: str, text: str = '') -> bool:
181
+
182
+ # Header
183
+ print(
184
+ f'{Colors.BOLD} - Delete {description}: Confirm "'
185
+ f'{Colors.RED}{text}'
186
+ f'{Colors.BOLD}" deletion:'
187
+ f'{Colors.RESET}', end='')
188
+ Platform.flush()
189
+
190
+ # Get user configuration
191
+ answer: bool = questionary.confirm(
192
+ message='',
193
+ default=False,
194
+ qmark='',
195
+ style=Themes.confirmation_style(),
196
+ auto_enter=True,
197
+ ).ask()
198
+
199
+ # Result
200
+ return answer
201
+
176
202
  # Group
177
203
  @staticmethod
178
204
  def group(
@@ -205,8 +231,15 @@ class Entrypoint:
205
231
  f'{Colors.RESET}')
206
232
  Platform.flush()
207
233
 
208
- # Delete group
234
+ # Delete group after validation
209
235
  if options.delete_group:
236
+ if not Entrypoint.confirm(
237
+ group_type,
238
+ group.full_path,
239
+ ):
240
+ return Entrypoint.Result.SUCCESS
241
+
242
+ # Delete group
210
243
  gitlab.group_delete(criteria)
211
244
  print(f'{Colors.BOLD} - Delete {group_type}: '
212
245
  f'{Colors.GREEN}Success'
@@ -289,8 +322,15 @@ class Entrypoint:
289
322
  f'{Colors.RESET}')
290
323
  Platform.flush()
291
324
 
292
- # Delete project
325
+ # Delete project after validation
293
326
  if options.delete_project:
327
+ if not Entrypoint.confirm(
328
+ 'project',
329
+ project.path_with_namespace,
330
+ ):
331
+ return Entrypoint.Result.SUCCESS
332
+
333
+ # Delete project
294
334
  gitlab.project_delete(criteria)
295
335
  print(f'{Colors.BOLD} - Delete project: '
296
336
  f'{Colors.GREEN}Success'
@@ -14,6 +14,7 @@ from ..package.updates import Updates
14
14
  from ..package.version import Version
15
15
  from ..prints.colors import Colors
16
16
  from ..system.platform import Platform
17
+ from ..types.gitlab import ProtectionLevels
17
18
  from .entrypoint import Entrypoint
18
19
 
19
20
  # Main, pylint: disable=too-many-statements
@@ -216,7 +217,10 @@ def main() -> None:
216
217
  dest='protect_tags',
217
218
  action='store',
218
219
  metavar='LEVEL',
219
- help='Protect tags at level [no-one,admins,maintainers,developers]',
220
+ nargs='?',
221
+ const=ProtectionLevels.default(),
222
+ help=f'Protect tags at level [{",".join(ProtectionLevels.names())}]'
223
+ ' (default: %(const)s)',
220
224
  )
221
225
 
222
226
  # Arguments positional definitions
@@ -232,7 +236,7 @@ def main() -> None:
232
236
  action='store',
233
237
  nargs='?',
234
238
  default='https://gitlab.com',
235
- help='GitLab URL (default: https://gitlab.com)',
239
+ help='GitLab URL (default: %(default)s)',
236
240
  )
237
241
  group.add_argument(
238
242
  dest='path',
@@ -10,7 +10,7 @@ from gitlab.exceptions import GitlabDeleteError, GitlabGetError, GitlabListError
10
10
  from gitlab.v4.objects import Group, Namespace, Project, User
11
11
 
12
12
  # Components
13
- from ..types.gitlab import AccessLevels, ProjectFeatures
13
+ from ..types.gitlab import AccessLevels, ProjectFeatures, ProtectionLevels
14
14
 
15
15
  # GitLabFeature class, pylint: disable=too-many-public-methods
16
16
  class GitLabFeature:
@@ -349,13 +349,13 @@ class GitLabFeature:
349
349
 
350
350
  # Prepare access level
351
351
  access_level: int
352
- if protect_level == 'no-one':
352
+ if protect_level == ProtectionLevels.NO_ONE:
353
353
  access_level = 0
354
- elif protect_level == 'admins':
354
+ elif protect_level == ProtectionLevels.ADMINS:
355
355
  access_level = 60
356
- elif protect_level == 'maintainers':
356
+ elif protect_level == ProtectionLevels.MAINTAINERS:
357
357
  access_level = 40
358
- elif protect_level == 'developers':
358
+ elif protect_level == ProtectionLevels.DEVELOPERS:
359
359
  access_level = 30
360
360
  else:
361
361
  raise SyntaxError(f'Unknown protection level: {access_level}')
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env python3
2
+
3
+ # Modules libraries
4
+ try:
5
+ from prompt_toolkit.styles.style import Style as prompt_toolkit_styles_Style
6
+ except ModuleNotFoundError: # pragma: no cover
7
+ from typing import Any as prompt_toolkit_styles_Style # type: ignore[assignment]
8
+
9
+ # Components
10
+ from .colors import Colors
11
+
12
+ # Themes class, pylint: disable=too-few-public-methods
13
+ class Themes:
14
+
15
+ # Flags
16
+ __prepared = False
17
+
18
+ # Members
19
+ __bold: str = ''
20
+ __red: str = ''
21
+ __selected: str = ''
22
+
23
+ # Prepare
24
+ @staticmethod
25
+ def __prepare() -> None:
26
+
27
+ # Colors enabled
28
+ if Colors.enabled():
29
+ Themes.__bold = 'bold'
30
+ Themes.__red = '#FF0000 bold'
31
+ Themes.__selected = 'bold noreverse'
32
+
33
+ # Colors disabled
34
+ else:
35
+ Themes.__bold = 'noinherit bold'
36
+ Themes.__red = 'noinherit bold'
37
+ Themes.__selected = 'noinherit bold noreverse'
38
+
39
+ # Raise flag
40
+ Themes.__prepared = True
41
+
42
+ # Confirmation
43
+ @staticmethod
44
+ def confirmation_style() -> prompt_toolkit_styles_Style:
45
+
46
+ # Prepare
47
+ if not Themes.__prepared:
48
+ Themes.__prepare()
49
+
50
+ # Result
51
+ return prompt_toolkit_styles_Style([
52
+ ('answer', Themes.__red),
53
+ ('instruction', Themes.__red),
54
+ ('highlighted', Themes.__bold),
55
+ ('pointer', Themes.__bold),
56
+ ('qmark', Themes.__bold),
57
+ ('question', Themes.__bold),
58
+ ('selected', Themes.__selected),
59
+ ('separator', Themes.__bold),
60
+ ])
@@ -14,6 +14,28 @@ class AccessLevels:
14
14
  PRIVATE: str = 'private'
15
15
  ENABLED: str = 'enabled'
16
16
 
17
+ # ProtectionLevels class
18
+ class ProtectionLevels:
19
+ NO_ONE: str = 'no-one'
20
+ ADMINS: str = 'admins'
21
+ MAINTAINERS: str = 'maintainers'
22
+ DEVELOPERS: str = 'developers'
23
+
24
+ # Default
25
+ @staticmethod
26
+ def default() -> str:
27
+ return ProtectionLevels.NO_ONE
28
+
29
+ # Names
30
+ @staticmethod
31
+ def names() -> List[str]:
32
+ return [
33
+ ProtectionLevels.NO_ONE,
34
+ ProtectionLevels.ADMINS,
35
+ ProtectionLevels.MAINTAINERS,
36
+ ProtectionLevels.DEVELOPERS,
37
+ ]
38
+
17
39
  # Visibility class, pylint: disable=too-few-public-methods
18
40
  class Visibility:
19
41
  PRIVATE: str = 'private'