Fix parsing of SVN commits in PRs.

Message ID 45870df3-89ef-7e54-4e49-47c6c4e3b4ba@suse.cz
State New
Headers show
Series
  • Fix parsing of SVN commits in PRs.
Related show

Commit Message

Martin Liška May 29, 2020, 2:11 p.m.
Tested and pushed to master.

maintainer-scripts/ChangeLog:

	* bugzilla-close-candidate.py: Fix parsing of SVN revisions.
	Fix skipping of PRs that contain Can be closed message.
---
  .../bugzilla-close-candidate.py               | 36 +++++++++++--------
  1 file changed, 22 insertions(+), 14 deletions(-)

-- 
2.26.2

Patch

diff --git a/maintainer-scripts/bugzilla-close-candidate.py b/maintainer-scripts/bugzilla-close-candidate.py
index dfd67ac1cbb..9c95f2bf3eb 100755
--- a/maintainer-scripts/bugzilla-close-candidate.py
+++ b/maintainer-scripts/bugzilla-close-candidate.py
@@ -37,23 +37,27 @@  def get_branches_by_comments(comments):
      for c in comments:
          text = c['text']
          lines = text.split('\n')
-        for line in lines:
-            if 'URL: https://gcc.gnu.org/viewcvs' in line:
-                version = 'master'
+        if 'URL: https://gcc.gnu.org/viewcvs' in text:
+            version = 'master'
+            for line in lines:
                  if 'branches/gcc-' in line:
                      parts = line.strip().split('/')
                      parts = parts[1].split('-')
                      assert len(parts) == 3
-                    versions.add(parts[1])
-                versions.add(version)
-            elif line.startswith('The ') and 'branch has been updated' in line:
-                version = 'master'
-                name = line.strip().split(' ')[1]
-                if '/' in name:
-                    name = name.split('/')[1]
-                    assert '-' in name
-                    version = name.split('-')[1]
-                versions.add(version)
+                    version = parts[1]
+                    break
+            versions.add(version)
+        else:
+            for line in lines:
+                if line.startswith('The ') and 'branch has been updated' in line:
+                    version = 'master'
+                    name = line.strip().split(' ')[1]
+                    if '/' in name:
+                        name = name.split('/')[1]
+                        assert '-' in name
+                        version = name.split('-')[1]
+                    versions.add(version)
+                    break
      return versions
  
  def get_bugs(query):
@@ -79,9 +83,13 @@  def search():
              keys = list(r['bugs'].keys())
              assert len(keys) == 1
              comments = r['bugs'][keys[0]]['comments']
+            skip = False
              for c in comments:
                  if closure_question in c['text']:
-                    continue
+                    skip = True
+                    break
+            if skip:
+                continue
  
              branches = get_branches_by_comments(comments)
              if len(branches):