Skip to content
This repository was archived by the owner on May 29, 2026. It is now read-only.

Commit 37e2cbf

Browse files
committed
quick fix
1 parent 4a0fb49 commit 37e2cbf

1 file changed

Lines changed: 246 additions & 13 deletions

File tree

  • prevent-cli/src/prevent_cli/commands

prevent-cli/src/prevent_cli/commands/upload.py

Lines changed: 246 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,266 @@
11
import logging
2+
import os
23
import pathlib
34
import typing
45

56
import click
67
import sentry_sdk
7-
from codecov_cli.commands.upload import global_upload_options
88
from codecov_cli.helpers.args import get_cli_args
9-
from codecov_cli.helpers.options import global_options
109
from codecov_cli.helpers.upload_type import report_type_from_str
1110
from codecov_cli.opentelemetry import close_telem
1211
from codecov_cli.services.upload_coverage import upload_coverage_logic
1312

13+
14+
def _turn_env_vars_into_dict(ctx, params, value):
15+
return dict((v, os.getenv(v, None)) for v in value)
16+
17+
18+
_global_options = [
19+
click.option(
20+
"-C",
21+
"--sha",
22+
"--commit-sha",
23+
"commit_sha",
24+
help="Commit SHA (with 40 chars)",
25+
required=True,
26+
),
27+
click.option(
28+
"-Z",
29+
"--fail-on-error",
30+
"fail_on_error",
31+
is_flag=True,
32+
help="Exit with non-zero code in case of error",
33+
),
34+
click.option(
35+
"--git-service",
36+
help="Git service provider",
37+
type=click.Choice(
38+
[
39+
"github",
40+
"gitlab",
41+
"bitbucket",
42+
"github_enterprise",
43+
"gitlab_enterprise",
44+
"bitbucket_server",
45+
]
46+
),
47+
),
48+
click.option(
49+
"-t",
50+
"--token",
51+
help="Codecov upload token",
52+
envvar="TOKEN",
53+
),
54+
click.option(
55+
"-r",
56+
"--slug",
57+
help="owner/repo slug used instead of the private repo token in Self-hosted",
58+
envvar="SLUG",
59+
),
60+
]
61+
62+
_global_upload_options = [
63+
click.option(
64+
"--code",
65+
"--report-code",
66+
"report_code",
67+
help="The code of the report. If unsure, leave default",
68+
default="default",
69+
hidden=True,
70+
),
71+
click.option(
72+
"--network-root-folder",
73+
help="Root folder from which to consider paths on the network section",
74+
type=click.Path(path_type=pathlib.Path),
75+
default=pathlib.Path.cwd,
76+
show_default="Current working directory",
77+
),
78+
click.option(
79+
"-s",
80+
"--dir",
81+
"--coverage-files-search-root-folder",
82+
"--files-search-root-folder",
83+
"files_search_root_folder",
84+
help="Folder where to search for coverage files",
85+
type=click.Path(path_type=pathlib.Path),
86+
default=pathlib.Path.cwd,
87+
show_default="Current Working Directory",
88+
),
89+
click.option(
90+
"--exclude",
91+
"--coverage-files-search-exclude-folder",
92+
"--files-search-exclude-folder",
93+
"files_search_exclude_folders",
94+
help="Folders to exclude from search",
95+
type=click.Path(path_type=pathlib.Path),
96+
multiple=True,
97+
default=[],
98+
),
99+
click.option(
100+
"-f",
101+
"--file",
102+
"--coverage-files-search-direct-file",
103+
"--files-search-direct-file",
104+
"files_search_explicitly_listed_files",
105+
help="Explicit files to upload. These will be added to the coverage files found for upload. If you wish to only upload the specified files, please consider using --disable-search to disable uploading other files.",
106+
type=click.Path(path_type=pathlib.Path),
107+
multiple=True,
108+
default=[],
109+
),
110+
click.option(
111+
"--recurse-submodules",
112+
help="Whether to enumerate files inside of submodules for path-fixing purposes. Off by default.",
113+
is_flag=True,
114+
default=False,
115+
),
116+
click.option(
117+
"--disable-search",
118+
help="Disable search for coverage files. This is helpful when specifying what files you want to upload with the --file option.",
119+
is_flag=True,
120+
default=False,
121+
),
122+
click.option(
123+
"--disable-file-fixes",
124+
help="Disable file fixes to ignore common lines from coverage (e.g. blank lines or empty brackets)",
125+
is_flag=True,
126+
default=False,
127+
),
128+
click.option(
129+
"-b",
130+
"--build",
131+
"--build-code",
132+
"build_code",
133+
help="Specify the build number manually",
134+
),
135+
click.option(
136+
"--build-url",
137+
"build_url",
138+
help="The URL of the build where this is running",
139+
),
140+
click.option(
141+
"--job-code",
142+
help="Specify the job code manually",
143+
),
144+
click.option(
145+
"-n",
146+
"--name",
147+
help="Custom defined name of the upload. Visible in Codecov UI",
148+
),
149+
click.option(
150+
"-B",
151+
"--branch",
152+
help="Branch to which this commit belongs to",
153+
),
154+
click.option(
155+
"-P",
156+
"--pr",
157+
"--pull-request-number",
158+
"pull_request_number",
159+
help="Specify the pull request number manually. Used to override pre-existing CI environment variables",
160+
),
161+
click.option(
162+
"-e",
163+
"--env",
164+
"--env-var",
165+
"env_vars",
166+
multiple=True,
167+
callback=_turn_env_vars_into_dict,
168+
help="Specify environment variables to be included with this build.",
169+
),
170+
click.option(
171+
"-F",
172+
"--flag",
173+
"flags",
174+
multiple=True,
175+
default=[],
176+
help="Flag the upload to group coverage metrics. Multiple flags allowed.",
177+
),
178+
click.option(
179+
"--plugin",
180+
"plugin_names",
181+
multiple=True,
182+
default=["xcode", "gcov", "pycoverage"],
183+
),
184+
click.option(
185+
"-d",
186+
"--dry-run",
187+
"dry_run",
188+
is_flag=True,
189+
help="Don't upload files to Codecov",
190+
),
191+
click.option(
192+
"--legacy",
193+
"--use-legacy-uploader",
194+
"use_legacy_uploader",
195+
is_flag=True,
196+
help="Use the legacy upload endpoint",
197+
),
198+
click.option(
199+
"--handle-no-reports-found",
200+
"handle_no_reports_found",
201+
is_flag=True,
202+
help="Raise no exceptions when no coverage reports found.",
203+
),
204+
click.option(
205+
"--report-type",
206+
"report_type_str",
207+
help="The type of report to upload",
208+
default="coverage",
209+
type=click.Choice(["coverage", "test-results", "test_results"]),
210+
),
211+
click.option(
212+
"--network-filter",
213+
help="Specify a filter on the files listed in the network section of the Codecov report. This will only add files whose path begin with the specified filter. Useful for upload-specific path fixing",
214+
),
215+
click.option(
216+
"--network-prefix",
217+
help="Specify a prefix on files listed in the network section of the Codecov report. Useful to help resolve path fixing",
218+
),
219+
click.option(
220+
"--gcov-args",
221+
help="Extra arguments to pass to gcov",
222+
),
223+
click.option(
224+
"--gcov-ignore",
225+
help="Paths to ignore during gcov gathering",
226+
),
227+
click.option(
228+
"--gcov-include",
229+
help="Paths to include during gcov gathering",
230+
),
231+
click.option(
232+
"--gcov-executable",
233+
help="gcov executable to run. Defaults to 'gcov'",
234+
),
235+
click.option(
236+
"--swift-project",
237+
help="Specify the swift project",
238+
),
239+
click.option(
240+
"--parent-sha",
241+
help="SHA (with 40 chars) of what should be the parent of this commit",
242+
),
243+
]
244+
245+
246+
def global_options(func):
247+
for option in reversed(_global_options):
248+
func = option(func)
249+
return func
250+
251+
252+
def global_upload_options(func):
253+
for option in reversed(_global_upload_options):
254+
func = option(func)
255+
return func
256+
257+
14258
logger = logging.getLogger("codecovcli")
15259

16260

17261
@click.command()
18262
@global_options
19263
@global_upload_options
20-
@click.option(
21-
"--parent-sha",
22-
help="SHA (with 40 chars) of what should be the parent of this commit",
23-
)
24-
@click.option(
25-
"--report-type",
26-
"report_type_str",
27-
help="The type of report to upload",
28-
default="coverage",
29-
type=click.Choice(["coverage", "test-results", "test_results"]),
30-
)
31264
@click.pass_context
32265
def upload(
33266
ctx: click.Context,

0 commit comments

Comments
 (0)