@@ -55,15 +55,31 @@ def main():
55
55
generate_stats_cli_command_logic (args , project_name , project_version )
56
56
57
57
58
- def trigger_tests_cli_command_logic (args , project_name , project_version ):
59
- logging .info (
60
- "Using: {project_name} {project_version}" .format (
61
- project_name = project_name , project_version = project_version
62
- )
63
- )
64
- if args .use_branch is False and args .use_tags is False :
65
- logging .error ("You must specify either --use-tags or --use-branch flag" )
66
- sys .exit (1 )
58
+ def get_commits (args , repo ):
59
+ total_commits = 0
60
+ commits = []
61
+ for commit in repo .iter_commits ():
62
+ commit_datetime = commit .committed_datetime
63
+ if (
64
+ args .from_date
65
+ <= datetime .datetime .utcfromtimestamp (commit_datetime .timestamp ())
66
+ <= args .to_date
67
+ ):
68
+ if (args .last_n > 0 and total_commits < args .last_n ) or args .last_n == - 1 :
69
+ total_commits = total_commits + 1
70
+ print (commit .summary )
71
+ commits .append (
72
+ {
73
+ "git_hash" : commit .hexsha ,
74
+ "git_branch" : repo .active_branch .name ,
75
+ "commit_summary" : commit .summary ,
76
+ "commit_datetime" : commit_datetime ,
77
+ }
78
+ )
79
+ return commits , total_commits
80
+
81
+
82
+ def get_repo (args ):
67
83
redisDirPath = args .redis_repo
68
84
cleanUp = False
69
85
if redisDirPath is None :
@@ -87,35 +103,33 @@ def trigger_tests_cli_command_logic(args, project_name, project_version):
87
103
redisDirPath
88
104
)
89
105
)
106
+ return redisDirPath , cleanUp
107
+
108
+
109
+ def trigger_tests_cli_command_logic (args , project_name , project_version ):
110
+ logging .info (
111
+ "Using: {project_name} {project_version}" .format (
112
+ project_name = project_name , project_version = project_version
113
+ )
114
+ )
115
+
116
+ if args .use_branch is False and args .use_tags is False :
117
+ logging .error ("You must specify either --use-tags or --use-branch flag" )
118
+ sys .exit (1 )
119
+
120
+ redisDirPath , cleanUp = get_repo (args )
121
+ repo = git .Repo (redisDirPath )
122
+
90
123
logging .info (
91
124
"Using the following timeframe: from {} to {}" .format (
92
125
args .from_date , args .to_date
93
126
)
94
127
)
95
- repo = git . Repo ( redisDirPath )
128
+
96
129
commits = []
97
- total_commits = 0
98
130
if args .use_branch :
99
- for commit in repo .iter_commits ():
100
- commit_datetime = str (commit .committed_datetime )
101
- if (
102
- args .from_date
103
- <= datetime .datetime .utcfromtimestamp (commit_datetime .timestamp ())
104
- <= args .to_date
105
- ):
106
- if (
107
- args .last_n > 0 and total_commits < args .last_n
108
- ) or args .last_n == - 1 :
109
- total_commits = total_commits + 1
110
- print (commit .summary )
111
- commits .append (
112
- {
113
- "git_hash" : commit .hexsha ,
114
- "git_branch" : repo .active_branch .name ,
115
- "commit_summary" : commit .summary ,
116
- "commit_datetime" : commit_datetime ,
117
- }
118
- )
131
+ commits , total_commits = get_commits (args , repo )
132
+
119
133
if args .use_tags :
120
134
tags_regexp = args .tags_regexp
121
135
if tags_regexp == ".*" :
@@ -137,7 +151,6 @@ def trigger_tests_cli_command_logic(args, project_name, project_version):
137
151
)
138
152
<= args .to_date
139
153
):
140
-
141
154
try :
142
155
version .Version (tag .name )
143
156
match_obj = re .search (tags_regex_string , tag .name )
@@ -221,7 +234,6 @@ def trigger_tests_cli_command_logic(args, project_name, project_version):
221
234
222
235
for rep in range (0 , 1 ):
223
236
for cdict in filtered_hash_commits :
224
-
225
237
(
226
238
result ,
227
239
error_msg ,
0 commit comments