Skip to content

Commit 2368b5a

Browse files
authored
CM-24619 - CLI pre-commit hook can't be installed properly (#135)
1 parent 67f0900 commit 2368b5a

File tree

5 files changed

+21
-3
lines changed

5 files changed

+21
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.DS_Store
12
.idea
23
*.iml
34
.env

.pre-commit-hooks.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
- id: cycode
22
name: Cycode pre commit defender
33
language: python
4+
language_version: python3
45
entry: cycode
5-
args: [ 'scan', 'pre_commit' ]
6+
args: [ '--no-progress-meter', 'scan', 'pre_commit' ]
67
- id: cycode-sca
78
name: Cycode SCA pre commit defender
89
language: python
10+
language_version: python3
911
entry: cycode
10-
args: [ 'scan', '--scan-type', 'sca', 'pre_commit' ]
12+
args: [ '--no-progress-meter', 'scan', '--scan-type', 'sca', 'pre_commit' ]

cycode/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,15 @@
11
__version__ = '0.0.0' # DON'T TOUCH. Placeholder. Will be filled automatically on poetry build from Git Tag
2+
3+
if __version__ == '0.0.1.dev1':
4+
# If CLI was installed from shallow clone, __version__ will be 0.0.1.dev1 due to non-strict versioning.
5+
# This happens when installing CLI as pre-commit hook.
6+
# We are not able to provide the version based on Git Tag in this case.
7+
# This fallback version is maintained manually.
8+
9+
# One benefit of it is that we could pass the version with a special suffix to mark pre-commit hook usage.
10+
11+
import os
12+
13+
version_filepath = os.path.join(os.path.dirname(__file__), 'pre-commit-hook-version')
14+
with open(version_filepath, 'r', encoding='UTF-8') as f:
15+
__version__ = f.read().strip()

cycode/pre-commit-hook-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.2.5-pre-commit

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ log_cli = true
5959
[tool.poetry-dynamic-versioning]
6060
# poetry self add "poetry-dynamic-versioning[plugin]"
6161
enable = true
62-
strict = true
62+
strict = false
6363
bump = true
6464
metadata = false
6565
vcs = "git"

0 commit comments

Comments
 (0)