5
5
6
6
from codecov_cli .fallbacks import CodecovOption , FallbackFieldEnum
7
7
from codecov_cli .helpers .args import get_cli_args
8
- from codecov_cli .helpers .git import GitService
9
8
from codecov_cli .helpers .options import global_options
9
+ from codecov_cli .services .commit import create_commit_logic
10
10
from codecov_cli .services .empty_upload import empty_upload_logic
11
11
from codecov_cli .types import CommandContext
12
12
15
15
16
16
@click .command ()
17
17
@click .option ("--force" , is_flag = True , default = False )
18
+ @click .option (
19
+ "--parent-sha" ,
20
+ help = "SHA (with 40 chars) of what should be the parent of this commit" ,
21
+ )
22
+ @click .option (
23
+ "-P" ,
24
+ "--pr" ,
25
+ "--pull-request-number" ,
26
+ "pull_request_number" ,
27
+ help = "Specify the pull request number mannually. Used to override pre-existing CI environment variables" ,
28
+ cls = CodecovOption ,
29
+ fallback_field = FallbackFieldEnum .pull_request_number ,
30
+ )
31
+ @click .option (
32
+ "-B" ,
33
+ "--branch" ,
34
+ help = "Branch to which this commit belongs to" ,
35
+ cls = CodecovOption ,
36
+ fallback_field = FallbackFieldEnum .branch ,
37
+ )
18
38
@global_options
19
39
@click .pass_context
20
40
def empty_upload (
@@ -25,9 +45,29 @@ def empty_upload(
25
45
token : typing .Optional [str ],
26
46
git_service : typing .Optional [str ],
27
47
fail_on_error : typing .Optional [bool ],
48
+ parent_sha : typing .Optional [str ],
49
+ pull_request_number : typing .Optional [int ],
50
+ branch : typing .Optional [str ],
28
51
):
52
+ logger .error ("Empty upload started" )
29
53
enterprise_url = ctx .obj .get ("enterprise_url" )
30
54
args = get_cli_args (ctx )
55
+
56
+ if parent_sha and pull_request_number and branch :
57
+ logger .debug ("Attempting to Create Commit before doing an empty upload." )
58
+ create_commit_logic (
59
+ commit_sha ,
60
+ parent_sha ,
61
+ pull_request_number ,
62
+ branch ,
63
+ slug ,
64
+ token ,
65
+ git_service ,
66
+ enterprise_url ,
67
+ fail_on_error ,
68
+ args ,
69
+ )
70
+
31
71
logger .debug (
32
72
"Starting empty upload process" ,
33
73
extra = dict (
0 commit comments