6
6
7
7
from codecov_cli .fallbacks import CodecovOption , FallbackFieldEnum
8
8
from codecov_cli .helpers .args import get_cli_args
9
- from codecov_cli .helpers .git import GitService
10
9
from codecov_cli .helpers .options import global_options
10
+ from codecov_cli .services .commit import create_commit_logic
11
11
from codecov_cli .services .empty_upload import empty_upload_logic
12
12
from codecov_cli .types import CommandContext
13
13
16
16
17
17
@click .command ()
18
18
@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 mannually. 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
+ )
19
39
@global_options
20
40
@click .pass_context
21
41
def empty_upload (
@@ -26,11 +46,30 @@ def empty_upload(
26
46
token : typing .Optional [str ],
27
47
git_service : typing .Optional [str ],
28
48
fail_on_error : typing .Optional [bool ],
49
+ parent_sha : typing .Optional [str ],
50
+ pull_request_number : typing .Optional [int ],
51
+ branch : typing .Optional [str ],
29
52
):
30
53
with sentry_sdk .start_transaction (op = "task" , name = "Empty Upload" ):
31
54
with sentry_sdk .start_span (name = "empty_upload" ):
32
55
enterprise_url = ctx .obj .get ("enterprise_url" )
33
56
args = get_cli_args (ctx )
57
+
58
+ if parent_sha and pull_request_number and branch :
59
+ logger .debug ("Attempting to Create Commit before doing an empty upload." )
60
+ create_commit_logic (
61
+ commit_sha ,
62
+ parent_sha ,
63
+ pull_request_number ,
64
+ branch ,
65
+ slug ,
66
+ token ,
67
+ git_service ,
68
+ enterprise_url ,
69
+ fail_on_error ,
70
+ args ,
71
+ )
72
+
34
73
logger .debug (
35
74
"Starting empty upload process" ,
36
75
extra = dict (
0 commit comments