@@ -105,27 +105,12 @@ def get_commits(
105
105
start : Optional [str ] = None ,
106
106
end : str = "HEAD" ,
107
107
* ,
108
- log_format : str = "%H%n%s%n%an%n%ae%n%b" ,
109
- delimiter : str = "----------commit-delimiter----------" ,
110
108
args : str = "" ,
111
109
) -> List [GitCommit ]:
112
110
"""Get the commits between start and end."""
113
- git_log_cmd = (
114
- f"git -c log.showSignature=False log --pretty={ log_format } { delimiter } { args } "
115
- )
116
-
117
- if start :
118
- command = f"{ git_log_cmd } { start } ..{ end } "
119
- else :
120
- command = f"{ git_log_cmd } { end } "
121
- c = cmd .run (command )
122
- if c .return_code != 0 :
123
- raise GitCommandError (c .err )
124
- if not c .out :
125
- return []
126
-
111
+ git_log_entries = _get_log_as_str_list (start , end , args )
127
112
git_commits = []
128
- for rev_and_commit in c . out . split ( f" { delimiter } \n " ) :
113
+ for rev_and_commit in git_log_entries :
129
114
if not rev_and_commit :
130
115
continue
131
116
rev , title , author , author_email , * body_list = rev_and_commit .split ("\n " )
@@ -236,3 +221,22 @@ def get_eol_style() -> EOLTypes:
236
221
def smart_open (* args , ** kargs ):
237
222
"""Open a file with the EOL style determined from Git."""
238
223
return open (* args , newline = get_eol_style ().get_eol_for_open (), ** kargs )
224
+
225
+
226
+ def _get_log_as_str_list (start : Optional [str ], end : str , args : str ) -> List [str ]:
227
+ """Get string representation of each log entry"""
228
+ delimiter = "----------commit-delimiter----------"
229
+ log_format : str = "%H%n%s%n%an%n%ae%n%b"
230
+ git_log_cmd = (
231
+ f"git -c log.showSignature=False log --pretty={ log_format } { delimiter } { args } "
232
+ )
233
+ if start :
234
+ command = f"{ git_log_cmd } { start } ..{ end } "
235
+ else :
236
+ command = f"{ git_log_cmd } { end } "
237
+ c = cmd .run (command )
238
+ if c .return_code != 0 :
239
+ raise GitCommandError (c .err )
240
+ if not c .out :
241
+ return []
242
+ return c .out .split (f"{ delimiter } \n " )
0 commit comments