Skip to content
This repository was archived by the owner on Jul 16, 2025. It is now read-only.

Commit c51b6b1

Browse files
Merge branch 'main' into th/no-git-list-files
2 parents 1edb142 + 6533a8c commit c51b6b1

File tree

12 files changed

+91
-56
lines changed

12 files changed

+91
-56
lines changed

codecov_cli/commands/commit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"--pr",
2525
"--pull-request-number",
2626
"pull_request_number",
27-
help="Specify the pull request number mannually. Used to override pre-existing CI environment variables",
27+
help="Specify the pull request number manually. Used to override pre-existing CI environment variables",
2828
cls=CodecovOption,
2929
fallback_field=FallbackFieldEnum.pull_request_number,
3030
)

codecov_cli/commands/empty_upload.py

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
from codecov_cli.fallbacks import CodecovOption, FallbackFieldEnum
88
from codecov_cli.helpers.args import get_cli_args
9-
from codecov_cli.helpers.git import GitService
109
from codecov_cli.helpers.options import global_options
10+
from codecov_cli.services.commit import create_commit_logic
1111
from codecov_cli.services.empty_upload import empty_upload_logic
1212
from codecov_cli.types import CommandContext
1313

@@ -16,6 +16,26 @@
1616

1717
@click.command()
1818
@click.option("--force", is_flag=True, default=False)
19+
@click.option(
20+
"--parent-sha",
21+
help="SHA (with 40 chars) of what should be the parent of this commit",
22+
)
23+
@click.option(
24+
"-P",
25+
"--pr",
26+
"--pull-request-number",
27+
"pull_request_number",
28+
help="Specify the pull request number manually. Used to override pre-existing CI environment variables",
29+
cls=CodecovOption,
30+
fallback_field=FallbackFieldEnum.pull_request_number,
31+
)
32+
@click.option(
33+
"-B",
34+
"--branch",
35+
help="Branch to which this commit belongs to",
36+
cls=CodecovOption,
37+
fallback_field=FallbackFieldEnum.branch,
38+
)
1939
@global_options
2040
@click.pass_context
2141
def empty_upload(
@@ -26,11 +46,29 @@ def empty_upload(
2646
token: typing.Optional[str],
2747
git_service: typing.Optional[str],
2848
fail_on_error: typing.Optional[bool],
49+
parent_sha: typing.Optional[str],
50+
pull_request_number: typing.Optional[int],
51+
branch: typing.Optional[str],
2952
):
3053
with sentry_sdk.start_transaction(op="task", name="Empty Upload"):
3154
with sentry_sdk.start_span(name="empty_upload"):
3255
enterprise_url = ctx.obj.get("enterprise_url")
3356
args = get_cli_args(ctx)
57+
58+
logger.debug("Attempting to Create Commit before doing an empty upload.")
59+
create_commit_logic(
60+
commit_sha,
61+
parent_sha,
62+
pull_request_number,
63+
branch,
64+
slug,
65+
token,
66+
git_service,
67+
enterprise_url,
68+
fail_on_error,
69+
args,
70+
)
71+
3472
logger.debug(
3573
"Starting empty upload process",
3674
extra=dict(

codecov_cli/commands/labelanalysis.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
logger = logging.getLogger("codecovcli")
2424

2525

26-
@click.command()
26+
@click.command(hidden=True, deprecated=True)
2727
@click.option(
2828
"--token",
2929
required=True,
@@ -141,7 +141,9 @@ def label_analysis(
141141
logger.info(f"Collected {len(requested_labels)} test labels")
142142
logger.debug(
143143
"Labels collected",
144-
extra=dict(extra_log_attributes=dict(labels_collected=requested_labels)),
144+
extra=dict(
145+
extra_log_attributes=dict(labels_collected=requested_labels)
146+
),
145147
)
146148
payload["requested_labels"] = requested_labels
147149

codecov_cli/commands/report.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"--pr",
2222
"--pull-request-number",
2323
"pull_request_number",
24-
help="Specify the pull request number mannually. Used to override pre-existing CI environment variables",
24+
help="Specify the pull request number manually. Used to override pre-existing CI environment variables",
2525
cls=CodecovOption,
2626
fallback_field=FallbackFieldEnum.pull_request_number,
2727
)

codecov_cli/commands/staticanalysis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
logger = logging.getLogger("codecovcli")
1616

1717

18-
@click.command()
18+
@click.command(hidden=True, deprecated=True)
1919
@click.option(
2020
"--foldertosearch",
2121
default=".",

codecov_cli/commands/upload.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def _turn_env_vars_into_dict(ctx, params, value):
124124
"--pr",
125125
"--pull-request-number",
126126
"pull_request_number",
127-
help="Specify the pull request number mannually. Used to override pre-existing CI environment variables",
127+
help="Specify the pull request number manually. Used to override pre-existing CI environment variables",
128128
cls=CodecovOption,
129129
fallback_field=FallbackFieldEnum.pull_request_number,
130130
),

codecovcli_commands

Lines changed: 12 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ Commands:
1717
do-upload
1818
empty-upload
1919
get-report-results
20-
label-analysis
2120
pr-base-picking
2221
process-test-results
2322
send-notifications
24-
static-analysis
2523
upload-coverage
2624
upload-process
2725

@@ -31,7 +29,7 @@ Options:
3129
--parent-sha TEXT SHA (with 40 chars) of what should be the
3230
parent of this commit
3331
-P, --pr, --pull-request-number TEXT
34-
Specify the pull request number mannually.
32+
Specify the pull request number manually.
3533
Used to override pre-existing CI environment
3634
variables
3735
-B, --branch TEXT Branch to which this commit belongs to
@@ -49,7 +47,7 @@ Options:
4947
--code TEXT The code of the report. If unsure, leave
5048
default
5149
-P, --pr, --pull-request-number TEXT
52-
Specify the pull request number mannually.
50+
Specify the pull request number manually.
5351
Used to override pre-existing CI environment
5452
variables
5553
-C, --sha, --commit-sha TEXT Commit SHA (with 40 chars) [required]
@@ -109,7 +107,7 @@ Options:
109107
in Codecov UI
110108
-B, --branch TEXT Branch to which this commit belongs to
111109
-P, --pr, --pull-request-number TEXT
112-
Specify the pull request number mannually.
110+
Specify the pull request number manually.
113111
Used to override pre-existing CI environment
114112
variables
115113
-e, --env, --env-var TEXT Specify environment variables to be included
@@ -151,6 +149,13 @@ Usage: codecovcli empty-upload [OPTIONS]
151149

152150
Options:
153151
--force
152+
--parent-sha TEXT SHA (with 40 chars) of what should be the
153+
parent of this commit
154+
-P, --pr, --pull-request-number TEXT
155+
Specify the pull request number manually.
156+
Used to override pre-existing CI environment
157+
variables
158+
-B, --branch TEXT Branch to which this commit belongs to
154159
-C, --sha, --commit-sha TEXT Commit SHA (with 40 chars) [required]
155160
-Z, --fail-on-error Exit with non-zero code in case of error
156161
--git-service [github|gitlab|bitbucket|github_enterprise|gitlab_enterprise|bitbucket_server]
@@ -172,28 +177,6 @@ Options:
172177
repo token in Self-hosted
173178
-h, --help Show this message and exit.
174179

175-
Usage: codecovcli label-analysis [OPTIONS]
176-
177-
Options:
178-
--token TEXT The static analysis token (NOT the same
179-
token as upload) [required]
180-
--head-sha TEXT Commit SHA (with 40 chars) [required]
181-
--base-sha TEXT Commit SHA (with 40 chars) [required]
182-
--runner-name, --runner TEXT Runner to use
183-
--max-wait-time INTEGER Max time (in seconds) to wait for the label
184-
analysis result before falling back to
185-
running all tests. Default is to wait
186-
forever.
187-
--dry-run Print list of tests to run AND tests skipped
188-
AND options that need to be added to the
189-
test runner to stdout. Choose format with
190-
--dry-run-format option. Default is JSON.
191-
--dry-run-format [json|space-separated-list]
192-
Format in which --dry-run data is printed.
193-
Default is JSON.
194-
--runner-param TEXT
195-
-h, --help Show this message and exit.
196-
197180
Usage: codecovcli pr-base-picking [OPTIONS]
198181

199182
Options:
@@ -238,19 +221,6 @@ Options:
238221
repo token in Self-hosted
239222
-h, --help Show this message and exit.
240223

241-
Usage: codecovcli static-analysis [OPTIONS]
242-
243-
Options:
244-
--foldertosearch PATH Folder to search
245-
--numberprocesses INTEGER number of processes to use
246-
--pattern TEXT file pattern to search for
247-
--force / --no-force
248-
--commit-sha TEXT Commit SHA (with 40 chars) [required]
249-
--folders-to-exclude PATH Folders not to search
250-
--token TEXT The static analysis token (NOT the same token as
251-
upload) [required]
252-
-h, --help Show this message and exit.
253-
254224
Usage: codecovcli upload-coverage [OPTIONS]
255225

256226
Options:
@@ -293,7 +263,7 @@ Options:
293263
in Codecov UI
294264
-B, --branch TEXT Branch to which this commit belongs to
295265
-P, --pr, --pull-request-number TEXT
296-
Specify the pull request number mannually.
266+
Specify the pull request number manually.
297267
Used to override pre-existing CI environment
298268
variables
299269
-e, --env, --env-var TEXT Specify environment variables to be included
@@ -369,7 +339,7 @@ Options:
369339
in Codecov UI
370340
-B, --branch TEXT Branch to which this commit belongs to
371341
-P, --pr, --pull-request-number TEXT
372-
Specify the pull request number mannually.
342+
Specify the pull request number manually.
373343
Used to override pre-existing CI environment
374344
variables
375345
-e, --env, --env-var TEXT Specify environment variables to be included

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ dependencies = [
1818
"regex",
1919
"responses==0.21.*",
2020
"sentry-sdk>=2.20.0",
21-
"test-results-parser==0.5.*",
21+
"test-results-parser==0.5.4",
2222
"tree-sitter==0.20.*",
2323
"wrapt>=1.17.2",
2424
]
2525
license = {file = "LICENSE"}
2626
name = "codecov-cli"
2727
readme = "README.md"
2828
requires-python = ">= 3.9"
29-
version = "10.2.0"
29+
version = "10.2.1"
3030

3131
[project.scripts]
3232
codecov = "codecov_cli.main:run"

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ sniffio==1.3.1
4747
# via
4848
# anyio
4949
# httpx
50-
test-results-parser==0.5.1
50+
test-results-parser==0.5.4
5151
# via codecov-cli (pyproject.toml)
5252
tree-sitter==0.20.4
5353
# via codecov-cli (pyproject.toml)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from click.testing import CliRunner
2+
3+
from codecov_cli.fallbacks import FallbackFieldEnum
4+
from codecov_cli.main import cli
5+
from tests.factory import FakeProvider, FakeVersioningSystem
6+
7+
def test_invoke_empty_upload_with_create_commit(mocker):
8+
create_commit_mock = mocker.patch("codecov_cli.commands.empty_upload.create_commit_logic")
9+
empty_upload_mock = mocker.patch("codecov_cli.commands.empty_upload.empty_upload_logic")
10+
11+
fake_ci_provider = FakeProvider({FallbackFieldEnum.commit_sha: None})
12+
mocker.patch("codecov_cli.main.get_ci_adapter", return_value=fake_ci_provider)
13+
14+
runner = CliRunner()
15+
result = runner.invoke(cli, ["empty-upload",
16+
"-C", "command-sha",
17+
"--slug", "owner/repo",
18+
"--parent-sha", "asdf",
19+
"--branch", "main",
20+
"--pr", 1234], obj={})
21+
assert result.exit_code == 0
22+
23+
create_commit_mock.assert_called_once()
24+
empty_upload_mock.assert_called_once()
25+

0 commit comments

Comments
 (0)