pre-commit-crocodile 2.0.0__py3-none-any.whl

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 (31) hide show
  1. pre_commit_crocodile/__init__.py +5 -0
  2. pre_commit_crocodile/__main__.py +5 -0
  3. pre_commit_crocodile/assets/.cz.yaml +188 -0
  4. pre_commit_crocodile/assets/.pre-commit-config.yaml +68 -0
  5. pre_commit_crocodile/assets/__init__.py +0 -0
  6. pre_commit_crocodile/cli/__init__.py +0 -0
  7. pre_commit_crocodile/cli/entrypoint.py +414 -0
  8. pre_commit_crocodile/cli/main.py +269 -0
  9. pre_commit_crocodile/hooks/__init__.py +0 -0
  10. pre_commit_crocodile/hooks/configurations.py +322 -0
  11. pre_commit_crocodile/hooks/prepare_commit_message.py +258 -0
  12. pre_commit_crocodile/package/__init__.py +0 -0
  13. pre_commit_crocodile/package/bundle.py +34 -0
  14. pre_commit_crocodile/package/settings.py +148 -0
  15. pre_commit_crocodile/package/updates.py +228 -0
  16. pre_commit_crocodile/package/version.py +80 -0
  17. pre_commit_crocodile/prints/__init__.py +0 -0
  18. pre_commit_crocodile/prints/boxes.py +82 -0
  19. pre_commit_crocodile/prints/colors.py +85 -0
  20. pre_commit_crocodile/system/__init__.py +0 -0
  21. pre_commit_crocodile/system/commands.py +90 -0
  22. pre_commit_crocodile/system/platform.py +74 -0
  23. pre_commit_crocodile/types/__init__.py +0 -0
  24. pre_commit_crocodile/types/environments.py +92 -0
  25. pre_commit_crocodile/types/strings.py +152 -0
  26. pre_commit_crocodile-2.0.0.dist-info/LICENSE +201 -0
  27. pre_commit_crocodile-2.0.0.dist-info/METADATA +212 -0
  28. pre_commit_crocodile-2.0.0.dist-info/RECORD +31 -0
  29. pre_commit_crocodile-2.0.0.dist-info/WHEEL +5 -0
  30. pre_commit_crocodile-2.0.0.dist-info/entry_points.txt +3 -0
  31. pre_commit_crocodile-2.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,5 @@
1
+ # Components
2
+ from .package.version import Version
3
+
4
+ # Version
5
+ __version__ = Version.get()
@@ -0,0 +1,5 @@
1
+ # Components
2
+ from .cli.main import main
3
+
4
+ # Entrypoint
5
+ main()
@@ -0,0 +1,188 @@
1
+ ---
2
+ commitizen:
3
+
4
+ # commitizen configurations
5
+ always_signoff: true
6
+ bump_message: 'docs(changelog): regenerate release tag changes history'
7
+ changelog_incremental: false
8
+ major_version_zero: true
9
+ retry_after_failure: false
10
+ tag_format: $version
11
+ update_changelog_on_bump: false
12
+ use_shortcuts: true
13
+ version_provider: scm
14
+ version_scheme: pep440
15
+
16
+ # commitizen rules
17
+ # - Based upon 'cz_conventional_commits' original rules for Conventional Commits
18
+ # - Improved with 'Issue:' detailed messages examples and 'Signed-off-by' footer
19
+ # - Commit scope turned mandatory by the rules
20
+ # - Commit scope refactored with support for spaces and comma
21
+ # - Breaking change reimplemented with the standard '!' scope suffix
22
+ # - Questions simplified for professional usage
23
+ # - Type 'security' implemented for security related commits
24
+ # - Accept temporary commits starting with 'wip' or 'WIP'
25
+ name: cz_customize
26
+ customize:
27
+ example: |-
28
+ feat(scope): implement feature ABC in sources
29
+
30
+ Issue: #123
31
+ Details: Details about the changes
32
+ ---
33
+
34
+ Signed-off-by: Firstname LASTNAME <firstname.lastname@example.com>
35
+ info: |
36
+
37
+ ## Conventional Commits - Customized specification
38
+
39
+ The commit contains the following structural elements, to communicate
40
+ intent to the consumers of your library:
41
+
42
+ ### Commit type
43
+
44
+ fix: a commit of the type fix patches a bug in your codebase
45
+ (this correlates with PATCH in semantic versioning).
46
+
47
+ feat: a commit of the type feat introduces a new feature to the codebase
48
+ (this correlates with MINOR in semantic versioning).
49
+
50
+ Others: commit types other than fix: and feat: are allowed,
51
+ like chore:, docs:, style:, refactor:, perf:, test:, and others.
52
+
53
+ We also recommend improvement for commits that improve a current
54
+ implementation without adding a new feature or fixing a bug.
55
+
56
+ For temporary commits, start with 'wip' or 'WIP' to ignore commit validation.
57
+
58
+ ### Commit scope
59
+
60
+ A scope has to be provided to a commit’s type, to provide additional contextual information,
61
+ such as the changed file, the containing folder or a globally modified feature,
62
+ and is contained within parenthesis, e.g., feat(parser): add ability to parse arrays.
63
+
64
+ ### Commit breaking changes
65
+
66
+ BREAKING CHANGE: A commit with '!' before the ':' or that has the text BREAKING CHANGE:
67
+ at the beginning of its optional body or footer section introduces a breaking API change
68
+ (correlating with MAJOR in semantic versioning).
69
+ A BREAKING CHANGE can be part of commits of any type.
70
+
71
+ ### Commit syntax
72
+
73
+ Notice these types are not mandated by the conventional commits specification,
74
+ and have no implicit effect in semantic versioning (unless they include a BREAKING CHANGE).
75
+
76
+ <type>(mandatory scope)[optional !]: <description>
77
+
78
+ [optional body]
79
+
80
+ [optional footer]
81
+ message_template: "\
82
+ {{prefix}}\
83
+ ({{scope}})\
84
+ {% if is_breaking_change %}!{% endif %}\
85
+ : \
86
+ {{subject}}\
87
+ {% if body or footer %}\n{% endif %}\
88
+ {% if body %}\n{{body}}{% endif %}\
89
+ {% if footer %}\n{{footer}}{% endif %}\
90
+ {% if body or footer %}\n---{% endif %}\
91
+ "
92
+ questions:
93
+ - type: list
94
+ name: prefix
95
+ message: 'Type of the change :'
96
+ choices:
97
+ - value: fix
98
+ name: 'fix: Bug or issues fixes'
99
+ key: x
100
+ - value: feat
101
+ name: 'feat: New or extended feature'
102
+ key: f
103
+ - value: chore
104
+ name: 'chore: Changes to non-production code'
105
+ key: h
106
+ - value: docs
107
+ name: 'docs: Documentation only changes'
108
+ key: d
109
+ - value: style
110
+ name: 'style: Cosmetic changes only (white-space, formatting, etc)'
111
+ key: s
112
+ - value: refactor
113
+ name: 'refactor: Code changes that neither fix a bug nor add a feature'
114
+ key: r
115
+ - value: perf
116
+ name: 'perf: Code change that improve performance'
117
+ key: p
118
+ - value: security
119
+ name: 'security: Changes that improve sources without any impact'
120
+ key: e
121
+ - value: test
122
+ name: 'test: Adding missing or correcting existing tests'
123
+ key: t
124
+ - value: build
125
+ name: 'build: Changes to the build system or dependencies _(example: makefile, pip, docker)'
126
+ key: b
127
+ - value: ci
128
+ name: 'ci: Changes to CI configuration files and scripts (example: gitlab-ci)'
129
+ key: c
130
+ - value: improvement
131
+ name: 'improvement: Changes that improve sources without any impact'
132
+ key: i
133
+ - type: input
134
+ name: scope
135
+ message: 'Scope of the change :'
136
+ filter: 'lambda text: commitizen.cz.utils.required_validator(text, msg="! Error: Scope is required")'
137
+ default: ''
138
+ - type: input
139
+ name: subject
140
+ message: 'Title of the commit (starting in lower case and without period) :'
141
+ filter: 'lambda text: commitizen.cz.utils.required_validator(text.strip(".").strip(), msg="! Error: Title is required")'
142
+ default: ''
143
+ - type: input
144
+ name: body
145
+ message: 'Additional contextual message (Empty to skip) :'
146
+ default: 'Issue: #...'
147
+ filter: 'commitizen.cz.utils.multiple_line_breaker'
148
+ - type: input
149
+ name: footer
150
+ message: 'Footer information and references (Empty to skip) :'
151
+ default: ''
152
+ - type: confirm
153
+ message: 'BREAKING CHANGE to warn ?'
154
+ name: is_breaking_change
155
+ default: False
156
+ schema: |-
157
+ <type>(<scope>): <subject>
158
+ <BLANK LINE>
159
+ <body>
160
+ <BLANK LINE>
161
+ <footer>
162
+ schema_pattern: "\
163
+ (?s)\
164
+ ^(wip|WIP).*$\
165
+ |\
166
+ (fix|feat|chore|docs|style|refactor|perf|test|build|ci|improvement|security|revert)\
167
+ (\\([^\\n\\r]+\\))\
168
+ !?\
169
+ :\
170
+ \
171
+ ([^\\n\\r]+)\
172
+ ((\\n\\n.*)|(\\s*))?\
173
+ (\\n[^\\n\r]+-by:.*)*\
174
+ $\
175
+ "
176
+
177
+ # commitizen styles
178
+ style:
179
+ - ["qmark", "fg:#FF9D00 bold"]
180
+ - ["question", "bold"]
181
+ - ["answer", "fg:#FF9D00 bold"]
182
+ - ["pointer", "fg:#FF9D00 bold"]
183
+ - ["highlighted", "fg:#FF9D00 bold"]
184
+ - ["selected", "fg:#CC5454"]
185
+ - ["separator", "fg:#CC5454"]
186
+ - ["instruction", ""]
187
+ - ["text", ""]
188
+ - ["disabled", "fg:#858585 italic"]
@@ -0,0 +1,68 @@
1
+ # pre-commit configurations
2
+ default_install_hook_types:
3
+ - prepare-commit-msg
4
+ - pre-commit
5
+ - pre-push
6
+ default_stages:
7
+ - prepare-commit-msg
8
+ - pre-commit
9
+ - pre-push
10
+ minimum_pre_commit_version: 3.8.0
11
+
12
+ # pre-commit exclusions
13
+ exclude: >
14
+ (?x)(
15
+ \.svg$|
16
+ CHANGELOG.md$|
17
+ COPYING.*$|
18
+ LICENSE.*$|
19
+ README.md$
20
+ )
21
+
22
+ # pre-commit repositories
23
+ repos:
24
+
25
+ # Repository: pre-commit
26
+ - repo: meta
27
+ hooks:
28
+ - id: check-hooks-apply
29
+ - id: check-useless-excludes
30
+
31
+ # Repository: pre-commit-hooks
32
+ - repo: https://github.com/pre-commit/pre-commit-hooks
33
+ rev: v4.6.0
34
+ hooks:
35
+ - id: check-added-large-files
36
+ args: ['--maxkb=500']
37
+ - id: check-case-conflict
38
+ - id: check-executables-have-shebangs
39
+ - id: check-json
40
+ - id: check-merge-conflict
41
+ - id: check-toml
42
+ - id: check-xml
43
+ - id: check-yaml
44
+ args: ['--unsafe']
45
+ - id: destroyed-symlinks
46
+ - id: detect-private-key
47
+ - id: double-quote-string-fixer
48
+ - id: end-of-file-fixer
49
+ - id: mixed-line-ending
50
+ - id: trailing-whitespace
51
+ args: ['--markdown-linebreak-ext=md']
52
+
53
+ # Repository: commitizen
54
+ - repo: https://github.com/commitizen-tools/commitizen
55
+ rev: v3.29.0
56
+ hooks:
57
+ - id: commitizen
58
+ - id: commitizen-branch
59
+ entry: cz
60
+ args: [--no-raise, '3', check, --rev-range, origin/HEAD..HEAD]
61
+ stages:
62
+ - push
63
+
64
+ # Repository: pre-commit-crocodile
65
+ - repo: https://gitlab.com/RadianDevCore/tools/pre-commit-crocodile
66
+ rev: {PACKAGE_REVISION}
67
+ hooks:
68
+ - id: prepare-commit-message
File without changes
File without changes
@@ -0,0 +1,414 @@
1
+ #!/usr/bin/env python3
2
+
3
+ # Standard libraries
4
+ from argparse import Namespace
5
+ from enum import Enum
6
+ from importlib.resources import files as resources_files
7
+ from os import linesep
8
+ from pathlib import Path
9
+ from time import sleep
10
+ from typing import List
11
+
12
+ # Components
13
+ from ..package.bundle import Bundle
14
+ from ..package.version import Version
15
+ from ..prints.colors import Colors
16
+ from ..system.commands import Commands
17
+ from ..system.platform import Platform
18
+
19
+ # Entrypoint class, pylint: disable=too-few-public-methods,too-many-statements
20
+ class Entrypoint:
21
+
22
+ # Constants
23
+ ARGCOMPLETE_BINARY: str = 'activate-global-python-argcomplete'
24
+ ARGCOMPLETE_MARKER: str = 'added by argcomplete'
25
+ COMMITIZEN_BINARY: str = 'cz'
26
+ COMMITIZEN_MARKER: str = '# register-python-argcomplete cz'
27
+ COMMITIZEN_PACKAGE: str = 'commitizen'
28
+ COMMITIZEN_SOURCES: str = 'git+https://github.com/AdrianDC/commitizen.git@prerelease'
29
+ COMMITIZEN_VERSION: str = '3.29.0.AdrianDC.20240813'
30
+ GIT_BINARY: str = 'git'
31
+ PRECOMMIT_BINARY: str = 'pre-commit'
32
+ PRECOMMIT_HOOKS_APPLY_ERROR: str = ' does not apply to this repository'
33
+ PRECOMMIT_PACKAGE: str = 'pre-commit'
34
+
35
+ # Configurations
36
+ CONFIGURATION_COMMITIZEN_FILE: str = '.cz.yaml'
37
+ CONFIGURATION_PRECOMMIT_FILE: str = '.pre-commit-config.yaml'
38
+ CONFIGURATIONS_ASSETS: List[str] = [
39
+ CONFIGURATION_COMMITIZEN_FILE,
40
+ CONFIGURATION_PRECOMMIT_FILE,
41
+ ]
42
+
43
+ # Enumerations
44
+ Result = Enum('Result', [
45
+ 'SUCCESS',
46
+ 'FINALIZE',
47
+ 'ERROR',
48
+ 'CRITICAL',
49
+ ])
50
+
51
+ # CLI, pylint: disable=too-many-branches,too-many-locals
52
+ @staticmethod
53
+ def cli(options: Namespace, ) -> Result:
54
+
55
+ # Variables
56
+ data_lines: List[str]
57
+ git_remotes: List[str]
58
+ hooks_unused: List[str]
59
+ user_bashrc: Path
60
+ user_home: Path = Path.home()
61
+
62
+ # List hooks
63
+ if options.list:
64
+
65
+ # Detect hooks directory
66
+ hooks_dir = Commands.output(Entrypoint.GIT_BINARY, [
67
+ 'rev-parse',
68
+ '--git-path',
69
+ 'hooks',
70
+ ])
71
+
72
+ # List hooks directory
73
+ if Path(hooks_dir).exists():
74
+
75
+ # Detect hooks files
76
+ hooks_files = [
77
+ hook.name for hook in Path(hooks_dir).iterdir()
78
+ if hook.is_file() and '.' not in hook.name
79
+ ]
80
+
81
+ # List hooks files
82
+ if hooks_files:
83
+ print(' ')
84
+ print(f'{Colors.BOLD} - List hooks: '
85
+ f'{Colors.GREEN}Hooks installed in "{hooks_dir}"'
86
+ f'{Colors.RESET}')
87
+ print(' ')
88
+ for hook in hooks_files:
89
+ print(f'{Colors.BOLD} - Hook: {Colors.RESET}{hook}')
90
+ print(' ')
91
+ Platform.flush()
92
+
93
+ # Missing hooks files
94
+ else:
95
+ print(' ')
96
+ print(f'{Colors.BOLD} - List hooks: '
97
+ f'{Colors.YELLOW_LIGHT}No hooks installed in "{hooks_dir}"'
98
+ f'{Colors.RESET}')
99
+ print(' ')
100
+ Platform.flush()
101
+
102
+ # Missing hooks directory
103
+ else:
104
+ print(' ')
105
+ print(f'{Colors.BOLD} - List hooks: '
106
+ f'{Colors.RED}No hooks directory found in "{hooks_dir}"'
107
+ f'{Colors.RESET}')
108
+ print(' ')
109
+ Platform.flush()
110
+
111
+ # Prepare dependencies
112
+ if options.install or options.configure or options.enable or options.autoupdate \
113
+ or options.run:
114
+
115
+ # Install pre-commit dependency
116
+ if options.install or not Commands.exists(Entrypoint.PRECOMMIT_BINARY):
117
+ print(' ')
118
+ print(f'{Colors.BOLD} - Install dependencies: '
119
+ f'{Colors.YELLOW_LIGHT}pre-commit'
120
+ f'{Colors.RESET}')
121
+ print(' ')
122
+ Platform.flush()
123
+ if Commands.exists(Entrypoint.PRECOMMIT_BINARY):
124
+ Commands.pip([
125
+ 'uninstall',
126
+ Entrypoint.PRECOMMIT_PACKAGE,
127
+ ])
128
+ Commands.pip([
129
+ 'install',
130
+ Entrypoint.PRECOMMIT_PACKAGE,
131
+ ])
132
+
133
+ # Install commitizen dependency
134
+ if options.install or not Commands.exists(
135
+ Entrypoint.COMMITIZEN_BINARY) or Commands.output(
136
+ Entrypoint.COMMITIZEN_BINARY, [
137
+ 'version',
138
+ ]) != Entrypoint.COMMITIZEN_VERSION:
139
+ print(' ')
140
+ print(f'{Colors.BOLD} - Install dependencies: '
141
+ f'{Colors.YELLOW_LIGHT}commitizen'
142
+ f'{Colors.RESET}')
143
+ print(' ')
144
+ Platform.flush()
145
+ if Commands.exists(Entrypoint.COMMITIZEN_BINARY):
146
+ Commands.pip([
147
+ 'uninstall',
148
+ Entrypoint.COMMITIZEN_PACKAGE,
149
+ ])
150
+ Commands.pip([
151
+ 'install',
152
+ Entrypoint.COMMITIZEN_SOURCES,
153
+ ])
154
+
155
+ # Install argcomplete completion
156
+ if options.install and (not Commands.grep(
157
+ Path(user_home / '.bash_completion'),
158
+ Entrypoint.ARGCOMPLETE_MARKER,
159
+ ) or not Commands.grep(
160
+ Path(user_home / '.zshenv'),
161
+ Entrypoint.ARGCOMPLETE_MARKER,
162
+ )):
163
+ print(' ')
164
+ print(f'{Colors.BOLD} - Install bash completion: '
165
+ f'{Colors.YELLOW_LIGHT}argcomplete'
166
+ f'{Colors.RESET}')
167
+ print(' ')
168
+ Platform.flush()
169
+ Commands.run(Entrypoint.ARGCOMPLETE_BINARY, [
170
+ '--user',
171
+ ])
172
+ sleep(2)
173
+
174
+ # Detect user .bashrc
175
+ user_bashrc = user_home / '.bashrc'
176
+ if Path(user_home / '.bash_user.rc').exists():
177
+ user_bashrc = user_home / '.bash_user.rc'
178
+
179
+ # Install commitizen completion
180
+ if options.install and not Commands.grep(
181
+ user_bashrc,
182
+ Entrypoint.COMMITIZEN_MARKER,
183
+ ):
184
+ print(' ')
185
+ print(f'{Colors.BOLD} - Install dependencies: '
186
+ f'{Colors.YELLOW_LIGHT}commitizen completion'
187
+ f'{Colors.RESET}')
188
+ print(' ')
189
+ print(f'commitizen completion enabled in: {user_bashrc}')
190
+ Platform.flush()
191
+ with open(user_bashrc, encoding='utf8', mode='a') as f:
192
+ f.write(f'{linesep}')
193
+ f.write(f'# register-python-argcomplete cz{linesep}')
194
+ f.write(f'eval "$(register-python-argcomplete cz)"{linesep}')
195
+ sleep(1)
196
+
197
+ # Configure sources
198
+ if options.configure:
199
+
200
+ # Install sources configurations
201
+ print(' ')
202
+ print(f'{Colors.BOLD} - Configure sources: '
203
+ f'{Colors.YELLOW_LIGHT}{Bundle.NAME}'
204
+ f'{Colors.RESET}')
205
+ print(' ')
206
+
207
+ # Export assets files
208
+ for asset in Entrypoint.CONFIGURATIONS_ASSETS:
209
+ print(f'exporting configuration in {asset} configuration')
210
+ data: str = resources_files(Bundle.RESOURCES_ASSETS) \
211
+ .joinpath(asset) \
212
+ .read_text(encoding='utf8') \
213
+ .replace('{PACKAGE_REVISION}', Version.revision())
214
+ with open(
215
+ asset,
216
+ encoding='utf8',
217
+ mode='w',
218
+ ) as f:
219
+ f.write(data)
220
+ sleep(1)
221
+
222
+ # Prestage pre-commit configuration
223
+ Commands.run(Entrypoint.GIT_BINARY, [
224
+ 'add',
225
+ Entrypoint.CONFIGURATION_PRECOMMIT_FILE,
226
+ ])
227
+
228
+ # Configure pre-commit unused hooks
229
+ print(' ')
230
+ print(f'{Colors.BOLD} - Configure sources: '
231
+ f'{Colors.YELLOW_LIGHT}check-hooks-apply'
232
+ f'{Colors.RESET}')
233
+ print(' ')
234
+ hooks_unused = []
235
+ for line in Commands.output(Entrypoint.PRECOMMIT_BINARY, [
236
+ 'run',
237
+ '--all-files',
238
+ 'check-hooks-apply',
239
+ ]).splitlines():
240
+ if Entrypoint.PRECOMMIT_HOOKS_APPLY_ERROR not in line:
241
+ continue
242
+ hooks_unused += [
243
+ line[0:line.find(Entrypoint.PRECOMMIT_HOOKS_APPLY_ERROR)]
244
+ ]
245
+
246
+ # Reset pre-commit configuration
247
+ Commands.run(Entrypoint.GIT_BINARY, [
248
+ 'reset',
249
+ 'HEAD',
250
+ Entrypoint.CONFIGURATION_PRECOMMIT_FILE,
251
+ ])
252
+
253
+ # Disable pre-commit unused hooks
254
+ if hooks_unused:
255
+ with open(
256
+ Entrypoint.CONFIGURATION_PRECOMMIT_FILE,
257
+ encoding='utf8',
258
+ mode='r',
259
+ ) as f:
260
+ data_lines = f.readlines()
261
+ with open(
262
+ Entrypoint.CONFIGURATION_PRECOMMIT_FILE,
263
+ encoding='utf8',
264
+ mode='w',
265
+ ) as f:
266
+ hook_offset: str
267
+ hook_section: bool = False
268
+ hook_id: str = '- id: '
269
+ for line in data_lines:
270
+ line_stripped = line.strip()
271
+ if not line_stripped:
272
+ f.write(line)
273
+ hook_section = False
274
+ elif any(line_stripped == f'{hook_id}{hook}'
275
+ for hook in hooks_unused):
276
+ f.write(line.replace(hook_id, f'# {hook_id}'))
277
+ hook_offset = line[0:line.find(hook_id)]
278
+ hook_section = True
279
+ elif line_stripped.startswith(hook_id):
280
+ f.write(line)
281
+ hook_section = False
282
+ elif hook_section:
283
+ f.write(f'{hook_offset}# {line.lstrip()}')
284
+ else:
285
+ f.write(line)
286
+
287
+ # Show sources status
288
+ print(' ')
289
+ Commands.run(Entrypoint.GIT_BINARY, [
290
+ 'status',
291
+ '--untracked-files',
292
+ ])
293
+
294
+ # Show commit hints
295
+ command_add: str = ' '.join([
296
+ Entrypoint.GIT_BINARY,
297
+ 'add',
298
+ '-v',
299
+ ] + [f'./{asset}' for asset in Entrypoint.CONFIGURATIONS_ASSETS])
300
+ command_commit: str = ' '.join([
301
+ Entrypoint.GIT_BINARY,
302
+ 'commit',
303
+ '-m',
304
+ f'"chore(pre-commit): import \'{Bundle.NAME}\' configurations"',
305
+ '-s',
306
+ ])
307
+ print(' ')
308
+ print(f'{Colors.BOLD}Add configurations: '
309
+ f'{Colors.CYAN}{command_add}'
310
+ f'{Colors.RESET}')
311
+ print(f'{Colors.BOLD}Commit changes: '
312
+ f'{Colors.CYAN}{command_commit}'
313
+ f'{Colors.RESET}')
314
+
315
+ # Delay user interactions
316
+ sleep(5)
317
+
318
+ # Enable hooks
319
+ if options.enable:
320
+
321
+ # Detect Git branches
322
+ git_remotes = [
323
+ branch.lstrip('*').strip()
324
+ for branch in Commands.output(Entrypoint.GIT_BINARY, [
325
+ 'remote',
326
+ ]).splitlines()
327
+ ]
328
+
329
+ # Enable Git hooks
330
+ print(' ')
331
+ print(f'{Colors.BOLD} - Enable hooks: '
332
+ f'{Colors.YELLOW_LIGHT}Git remote'
333
+ f'{Colors.RESET}')
334
+ print(' ')
335
+ print(f'detected Git remotes: {", ".join(git_remotes)}')
336
+ Platform.flush()
337
+ for remote in git_remotes:
338
+ print(f'updating git remote for {remote}')
339
+ Commands.run(Entrypoint.GIT_BINARY, [
340
+ 'remote',
341
+ 'set-head',
342
+ f'{remote}',
343
+ '-a',
344
+ ])
345
+
346
+ # Enable pre-commit hooks
347
+ print(' ')
348
+ print(f'{Colors.BOLD} - Enable hooks: '
349
+ f'{Colors.YELLOW_LIGHT}pre-commit'
350
+ f'{Colors.RESET}')
351
+ print(' ')
352
+ Platform.flush()
353
+ Commands.run(Entrypoint.PRECOMMIT_BINARY, [
354
+ 'install',
355
+ ])
356
+
357
+ # Disable hooks
358
+ if options.disable:
359
+
360
+ # Disable pre-commit hooks
361
+ print(' ')
362
+ print(f'{Colors.BOLD} - Disable hooks: '
363
+ f'{Colors.YELLOW_LIGHT}pre-commit'
364
+ f'{Colors.RESET}')
365
+ print(' ')
366
+ Platform.flush()
367
+ Commands.run(Entrypoint.PRECOMMIT_BINARY, [
368
+ 'uninstall',
369
+ ])
370
+
371
+ # Autoupdate hooks
372
+ if options.autoupdate:
373
+
374
+ # Autoupdate pre-commit hooks
375
+ print(' ')
376
+ print(f'{Colors.BOLD} - Autoupdate hooks: '
377
+ f'{Colors.YELLOW_LIGHT}pre-commit'
378
+ f'{Colors.RESET}')
379
+ print(' ')
380
+ Platform.flush()
381
+ Commands.run(Entrypoint.PRECOMMIT_BINARY, [
382
+ 'autoupdate',
383
+ ])
384
+
385
+ # Run hooks
386
+ if options.run:
387
+
388
+ # Run pre-commit hooks
389
+ print(' ')
390
+ print(f'{Colors.BOLD} - Run hooks: '
391
+ f'{Colors.YELLOW_LIGHT}pre-commit'
392
+ f'{Colors.RESET}')
393
+ print(' ')
394
+ Platform.flush()
395
+ Commands.run(Entrypoint.PRECOMMIT_BINARY, [
396
+ 'run',
397
+ '-a',
398
+ ])
399
+
400
+ # Run commitizen hooks
401
+ print(' ')
402
+ print(f'{Colors.BOLD} - Run hooks: '
403
+ f'{Colors.YELLOW_LIGHT}commitizen'
404
+ f'{Colors.RESET}')
405
+ print(' ')
406
+ Platform.flush()
407
+ Commands.run(Entrypoint.COMMITIZEN_BINARY, [
408
+ 'check',
409
+ '--rev-range',
410
+ 'HEAD~1..HEAD',
411
+ ])
412
+
413
+ # Result
414
+ return Entrypoint.Result.SUCCESS