@@ -44,7 +44,7 @@ def main():
4444 "log" ,
4545 "--oneline" ,
4646 "--first-parent" ,
47- f"-G^{ module } :" ,
47+ f"-G^{ re . escape ( module ) } :" ,
4848 "--" ,
4949 "versions.txt" ,
5050 ]
@@ -65,7 +65,7 @@ def main():
6565 continue # Ignore errors if file couldn't be read
6666
6767 # Find the line for the module
68- pattern = re .compile (rf"^{ module } :([^:]+):([^:]+)$" )
68+ pattern = re .compile (rf"^{ re . escape ( module ) } :([^:]+):([^:]+)$" )
6969 for line in content .splitlines ():
7070 match = pattern .match (line )
7171 if match :
@@ -75,7 +75,7 @@ def main():
7575 # Condition for target version
7676 if released_ver == target_version and not target_commit :
7777 target_commit = commit
78- print (f"Found target version { target_version } at { commit } " )
78+ print (f"Found target version { target_version } at { commit } " , file = sys . stderr )
7979
8080 # Condition for previous non-snapshot version
8181 # We ignore snapshot versions by checking both fields.
@@ -87,7 +87,7 @@ def main():
8787 ):
8888 prev_commit = commit
8989 prev_version = released_ver
90- print (f"Found previous version { released_ver } at { commit } " )
90+ print (f"Found previous version { released_ver } at { commit } " , file = sys . stderr )
9191 break
9292 if prev_commit :
9393 break
@@ -101,7 +101,7 @@ def main():
101101 # Fallback for initial version if no previous version found
102102 if not prev_commit :
103103 print (
104- f"Previous version not found in history for module { module } ."
104+ f"Previous version not found in history for module { module } ." , file = sys . stderr
105105 )
106106 # Find the first commit affecting that directory
107107 first_commit_cmd = [
@@ -116,16 +116,17 @@ def main():
116116 try :
117117 first_commit_output = run_cmd (first_commit_cmd )
118118 if first_commit_output :
119- prev_commit = first_commit_output . splitlines ()[ 0 ]. split ()[ 0 ]
120- print (f"Using first commit affecting directory as base: { prev_commit } " )
119+ prev_commit = None
120+ print (f"No previous version found. Generating notes from the beginning of history for { directory } ." , file = sys . stderr )
121121 else :
122- print (f"No history found for directory { directory } ." )
122+ print (f"No history found for directory { directory } ." , file = sys . stderr )
123123 sys .exit (1 )
124124 except SystemExit :
125125 sys .exit (1 )
126126
127+ range_desc = f"between { prev_commit } and { target_commit } " if prev_commit else f"up to { target_commit } "
127128 print (
128- f"Generating notes between { prev_commit } and { target_commit } for directory { directory } "
129+ f"Generating notes { range_desc } for directory { directory } " , file = sys . stderr
129130 )
130131
131132 # 2. Generate commit history in that range affecting that directory
@@ -136,7 +137,7 @@ def main():
136137 "log" ,
137138 "--format=%H %s%n%b%n--END_OF_COMMIT--" ,
138139 "--first-parent" ,
139- f"{ prev_commit } ..{ target_commit } " ,
140+ f"{ prev_commit } ..{ target_commit } " if prev_commit else target_commit ,
140141 "--" ,
141142 directory ,
142143 ]
0 commit comments