All of lore.kernel.org
 help / color / mirror / Atom feed
From: daniel.sangorrin@toshiba.co.jp (Daniel Sangorrin)
To: cip-dev@lists.cip-project.org
Subject: [cip-dev] [cip-kernel-sec][RESEND 3/6] report_affected: fix code when branches are specified
Date: Wed, 10 Jul 2019 10:24:47 +0900	[thread overview]
Message-ID: <20190710012450.16524-4-daniel.sangorrin@toshiba.co.jp> (raw)
In-Reply-To: <20190710012450.16524-1-daniel.sangorrin@toshiba.co.jp>

The previous code could not handle branches with names
other than stable branch names. For example, passing
"linux-4.4.y-cip" as a branch would return an error.

Signed-off-by: Daniel Sangorrin <daniel.sangorrin@toshiba.co.jp>
---
 scripts/kernel_sec/branch.py |  8 --------
 scripts/report_affected.py   | 23 +++++++++++++++++------
 2 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/scripts/kernel_sec/branch.py b/scripts/kernel_sec/branch.py
index 0023497..ef88b54 100644
--- a/scripts/kernel_sec/branch.py
+++ b/scripts/kernel_sec/branch.py
@@ -21,9 +21,6 @@ import yaml
 from . import version
 
 
-_STABLE_BRANCH_RE = re.compile(r'^linux-([\d.]+)\.y$')
-
-
 def get_base_ver_stable_branch(base_ver):
     branch_name = 'linux-%s.y' % base_ver
     return {
@@ -34,11 +31,6 @@ def get_base_ver_stable_branch(base_ver):
         }
 
 
-def get_stable_branch(branch_name):
-    match = _STABLE_BRANCH_RE.match(branch_name)
-    return match and get_base_ver_stable_branch(match.group(1))
-
-
 def _extract_live_stable_branches(doc):
     xhtml_ns = 'http://www.w3.org/1999/xhtml'
     ns = {'html': xhtml_ns}
diff --git a/scripts/report_affected.py b/scripts/report_affected.py
index d2f1f22..0ac27f6 100755
--- a/scripts/report_affected.py
+++ b/scripts/report_affected.py
@@ -18,14 +18,25 @@ import kernel_sec.version
 
 def main(git_repo, remotes,
          only_fixed_upstream, include_ignored, *branch_names):
+    live_branches = kernel_sec.branch.get_live_branches()
     if branch_names:
-        # Support stable release strings as shorthand for stable branches
-        branches = [kernel_sec.branch.get_base_ver_stable_branch(name)
-                    if name[0].isdigit()
-                    else kernel_sec.branch.get_stable_branch(name)
-                    for name in branch_names]
+        branches = []
+        for branch_name in branch_names:
+            if branch_name[0].isdigit():
+                # 4.4 is mapped to linux-4.4.y
+                name = 'linux-%s.y' % branch_name
+            else:
+                name = branch_name
+
+            for branch in live_branches:
+                if branch['short_name'] == name:
+                    branches.append(branch)
+                    break
+            else:
+                msg = "Branch %s could not be found" % branch_name
+                raise argparse.ArgumentError(None, msg)
     else:
-        branches = kernel_sec.branch.get_live_branches()
+        branches = live_branches
         if only_fixed_upstream:
             branches = [branch for branch in branches
                         if branch['short_name'] != 'mainline']
-- 
2.17.1

  parent reply	other threads:[~2019-07-10  1:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-10  1:24 [cip-dev] Add support for cip branches and tags Daniel Sangorrin
2019-07-10  1:24 ` [cip-dev] [cip-kernel-sec][RESEND 1/6] check_git_repo: add checks to the local repository Daniel Sangorrin
2019-07-10  1:24 ` [cip-dev] [cip-kernel-sec][RESEND 2/6] prepare_remotes: helper script to prepare local repo Daniel Sangorrin
2019-07-10  1:24 ` Daniel Sangorrin [this message]
2019-07-10  1:24 ` [cip-dev] [cip-kernel-sec][RESEND 4/6] report_affected: add support for reporting on tags Daniel Sangorrin
2019-07-10 14:40   ` Ben Hutchings
2019-07-11  4:50     ` daniel.sangorrin at toshiba.co.jp
2019-07-10  1:24 ` [cip-dev] [cip-kernel-sec][RESEND 5/6] pep8: fix pep8-related errors such as too long lines Daniel Sangorrin
2019-07-10  1:24 ` [cip-dev] [cip-kernel-sec][RESEND 6/6] report_affected: add show-description option Daniel Sangorrin
2019-07-10 15:02 ` [cip-dev] Add support for cip branches and tags Ben Hutchings

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190710012450.16524-4-daniel.sangorrin@toshiba.co.jp \
    --to=daniel.sangorrin@toshiba.co.jp \
    --cc=cip-dev@lists.cip-project.org \
    --subject='Re: [cip-dev] [cip-kernel-sec][RESEND 3/6] report_affected: fix code when branches are specified' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.