@@ -69,6 +69,7 @@ def sanity_check_filters(self):
6969 Check if the values passed by the user are correct.
7070
7171 """
72+ self ._check_correct_filters_order ()
7273 self .check_starting_commit ()
7374 self .check_ending_commit ()
7475 self ._check_timezones ()
@@ -83,8 +84,6 @@ def sanity_check_filters(self):
8384 self .set_value ("to_commit" , None )
8485 self .set_value ("single" , single )
8586
86- self ._check_correct_filters_order ()
87-
8887 if self .get ('single' ) is not None :
8988 if any ([self .get ('since' ),
9089 self .get ('to' ),
@@ -113,9 +112,7 @@ def _check_correct_filters_order(self):
113112 self .get ('git_repo' ).get_commit (self .get ('from_commit' )),
114113 self .get ('git_repo' ).get_commit (self .get ('to_commit' )))
115114
116- if self .get ('reversed_order' ) and chronological_order :
117- self ._swap_commit_fiters ()
118- elif not self .get ('reversed_order' ) and not chronological_order :
115+ if not chronological_order :
119116 self ._swap_commit_fiters ()
120117
121118 def _swap_commit_fiters (self ):
@@ -140,12 +137,17 @@ def check_starting_commit(self):
140137 raise Exception ('You can only specify one between since, '
141138 'from_tag and from_commit' )
142139 if self .get ('from_tag' ) is not None :
143- self .set_value ('from_commit' , self .get (
144- "git_repo" ).get_commit_from_tag (self .get ('from_tag' )).hash )
140+ self .set_value ('from_commit' , self .get ("git_repo" ).get_commit_from_tag (self .get ('from_tag' )).hash )
145141 if self .get ('from_commit' ):
146142 try :
147- self .set_value ('from_commit' , self .get ("git_repo" ).get_commit (
148- self .get ('from_commit' )).hash )
143+ commit = self .get ("git_repo" ).get_commit (self .get ('from_commit' ))
144+ if len (commit .parents ) == 0 :
145+ self .set_value ('from_commit' , [commit .hash ])
146+ elif len (commit .parents ) == 1 :
147+ self .set_value ('from_commit' , ['^' + commit .hash + '^' ])
148+ else :
149+ commits = ['^' + x for x in commit .parents ]
150+ self .set_value ('from_commit' , commits )
149151 except Exception :
150152 raise Exception ("The commit {} defined in the 'from_tag' "
151153 "or 'from_commit' filter does "
@@ -165,8 +167,8 @@ def check_ending_commit(self):
165167 "git_repo" ).get_commit_from_tag (self .get ('to_tag' )).hash )
166168 if self .get ('to_commit' ):
167169 try :
168- self . set_value ( 'to_commit' , self .get ("git_repo" ).get_commit (
169- self .get ('to_commit' )) .hash )
170+ commit = self .get ("git_repo" ).get_commit (self . get ( 'to_commit' ))
171+ self .set_value ('to_commit' , commit .hash )
170172 except Exception :
171173 raise Exception ("The commit {} defined in the 'to_tag' "
172174 "or 'to_commit' filter does "
@@ -182,6 +184,37 @@ def only_one_filter(arr):
182184 """
183185 return len ([x for x in arr if x is not None ]) <= 1
184186
187+ def build_args (self ):
188+ from_commit = self .get ('from_commit' )
189+ to_commit = self .get ('to_commit' )
190+ branch = self .get ('only_in_branch' )
191+
192+ args = []
193+
194+ if from_commit is not None or to_commit is not None :
195+ if from_commit is not None and to_commit is not None :
196+ args .extend (from_commit )
197+ args .append (to_commit )
198+ elif from_commit is not None :
199+ args .extend (from_commit )
200+ args .append ('HEAD' )
201+ else :
202+ args .append (to_commit )
203+ else :
204+ args .append ('HEAD' )
205+
206+ if branch is not None :
207+ args .append (branch )
208+
209+ if self .get ('only_no_merge' ):
210+ args .append ('--no-merges' )
211+
212+ if not self .get ('reversed_order' ):
213+ args .append ('--reverse' )
214+
215+ print (f'Returning args: { args } ' )
216+ return args
217+
185218 def is_commit_filtered (self , commit : Commit ):
186219 # pylint: disable=too-many-branches,too-many-return-statements
187220 """
@@ -201,22 +234,6 @@ def is_commit_filtered(self, commit: Commit):
201234 (self .get ('to' ) is not None and
202235 commit .committer_date > self .get ('to' )):
203236 return True
204- if self .get ('from_commit' ) is not None and \
205- self .get ('from_commit' ) == commit .hash :
206- self .set_value ('from_commit_started' , True )
207- return False
208- if self .get ('from_commit' ) is not None and \
209- self .get ('from_commit' ) != commit .hash and \
210- self .get ('from_commit_started' ) is None :
211- return True
212- if self .get ('to_commit' ) is not None and \
213- self .get ('to_commit' ) != commit .hash and \
214- self .get ('to_commit_reached' ) is not None :
215- return True
216- if self .get ('to_commit' ) is not None and \
217- self .get ('to_commit' ) == commit .hash :
218- self .set_value ('to_commit_reached' , True )
219- return False
220237 if self .get ('only_modifications_with_file_types' ) is not None :
221238 if not self ._has_modification_with_file_type (commit ):
222239 logger .debug ('Commit filtered for modification types' )
0 commit comments