Skip to content

Commit

Permalink
Update the empty upload command
Browse files Browse the repository at this point in the history
  • Loading branch information
michelletran-codecov committed Mar 11, 2025
1 parent e8dce24 commit 0703f0f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 31 deletions.
29 changes: 14 additions & 15 deletions codecov_cli/commands/empty_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"--pr",
"--pull-request-number",
"pull_request_number",
help="Specify the pull request number mannually. Used to override pre-existing CI environment variables",
help="Specify the pull request number manually. Used to override pre-existing CI environment variables",
cls=CodecovOption,
fallback_field=FallbackFieldEnum.pull_request_number,
)
Expand Down Expand Up @@ -55,20 +55,19 @@ def empty_upload(
enterprise_url = ctx.obj.get("enterprise_url")
args = get_cli_args(ctx)

if parent_sha and pull_request_number and branch:
logger.debug("Attempting to Create Commit before doing an empty upload.")
create_commit_logic(
commit_sha,
parent_sha,
pull_request_number,
branch,
slug,
token,
git_service,
enterprise_url,
fail_on_error,
args,
)
logger.debug("Attempting to Create Commit before doing an empty upload.")
create_commit_logic(
commit_sha,
parent_sha,
pull_request_number,
branch,
slug,
token,
git_service,
enterprise_url,
fail_on_error,
args,
)

logger.debug(
"Starting empty upload process",
Expand Down
7 changes: 7 additions & 0 deletions codecovcli_commands
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,13 @@ Usage: codecovcli empty-upload [OPTIONS]

Options:
--force
--parent-sha TEXT SHA (with 40 chars) of what should be the
parent of this commit
-P, --pr, --pull-request-number TEXT
Specify the pull request number mannually.
Used to override pre-existing CI environment
variables
-B, --branch TEXT Branch to which this commit belongs to
-C, --sha, --commit-sha TEXT Commit SHA (with 40 chars) [required]
-Z, --fail-on-error Exit with non-zero code in case of error
--git-service [github|gitlab|bitbucket|github_enterprise|gitlab_enterprise|bitbucket_server]
Expand Down
16 changes: 0 additions & 16 deletions tests/commands/test_invoke_empty_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,3 @@ def test_invoke_empty_upload_with_create_commit(mocker):
create_commit_mock.assert_called_once()
empty_upload_mock.assert_called_once()

def test_invoke_empty_upload_no_create_commit(mocker):
create_commit_mock = mocker.patch("codecov_cli.commands.empty_upload.create_commit_logic")
empty_upload_mock = mocker.patch("codecov_cli.commands.empty_upload.empty_upload_logic")

fake_ci_provider = FakeProvider({FallbackFieldEnum.commit_sha: None})
mocker.patch("codecov_cli.main.get_ci_adapter", return_value=fake_ci_provider)

runner = CliRunner()
result = runner.invoke(cli, ["empty-upload",
"-C", "command-sha",
"--slug", "owner/repo"], obj={})
assert result.exit_code == 0

create_commit_mock.assert_not_called()
empty_upload_mock.assert_called_once()

0 comments on commit 0703f0f

Please sign in to comment.