On 1/14/22 08:44, Bernhard Reutner-Fischer wrote:
On Wed, 12 Jan 2022 16:54:46 +0100
Martin Liška <mli...@suse.cz> wrote:

+def replace_file_in_changelog(lines, filename):
+    if not filename.endswith('.cc'):
+        return
+
+    # consider all componenets of a path: gcc/ipa-icf.cc
+    while filename:
+        for i, line in enumerate(lines):
+            if filename in line:
+                line = line.replace(filename, filename[:-1])
+                lines[i] = line
+                return
+        parts = filename.split('/')
+        if len(parts) == 1:
+            return
+        filename = '/'.join(parts[1:])
+

I think you mean os.sep instead of the hardcoded slash.
But i'd use os.path.split and os.path.join

Hello.

Well, these are all paths from a git commit message. And we require unix-style
of paths for all ChangeLog entries. So it should be correct.

Martin


thanks,

Reply via email to