Merge ~alextu/pc-enablement/+git/oem-scripts:bug-bind-private-bugs into ~oem-solutions-engineers/pc-enablement/+git/oem-scripts:master

Proposed by Alex Tu
Status: Merged
Merged at revision: 40d056151e17bec04021b8e22ab5260de06543ca
Proposed branch: ~alextu/pc-enablement/+git/oem-scripts:bug-bind-private-bugs
Merge into: ~oem-solutions-engineers/pc-enablement/+git/oem-scripts:master
Diff against target: 52 lines (+28/-2)
1 file modified
bug-bind.py (+28/-2)
Reviewer Review Type Date Requested Status
Shih-Yuan Lee Approve
Alex Tu (community) Needs Information
Review via email: mp+400920@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Alex Tu (alextu) wrote :

a testing was done on binding 1698071 1923297 1923298 to main bug 1876903

./bug-bind.py --main 1876903 1698071 1923297 1923298

Revision history for this message
Kai-Chuan Hsieh (kchsieh) wrote :

I only have suggestion about the parameter design, the rest looks good to me.

Revision history for this message
Shih-Yuan Lee (fourdollars) wrote :

It seems that we might need to restrict for certain explicit usages only.

For examples,
bug-bind.py --swe [id1] --public [id2] # Add the X-SWE-Bug: on id1 and tag originate-from-id1 on id2 public bug.
bug-bind.py --hwe [id1] --public [id2] # Add the X-HWE-Bug: on id1 and tag originate-from-id1 on id2 public bug.
bug-bind.py --swe [id1] --private [id2] # Add the X-SWE-Bug: on id1 and tag originate-from-id1 on id2 private bug.
bug-bind.py --hwe [id1] --private [id2] # Add the X-HWE-Bug: on id1 and tag originate-from-id1 on id2 private bug.
bug-bind.py --private [id1] --public [id2] # Only tag originate-from-id1 on id2 public bug and make sure id1 is private before the tag.

BTW, I would like rename bug-bind.py to bug-bind.

Revision history for this message
Alex Tu (alextu) wrote :

I feel this will confuse members for which one should he select.
Why can not we just reuse X-HWE-Bug only for public bugs?

bug-bind.py --swe [id1] --public [id2] # Add the X-SWE-Bug: on id1 and tag originate-from-id1 on id2 public bug.
bug-bind.py --hwe [id1] --public [id2] # Add the X-HWE-Bug: on id1 and tag originate-from-id1 on id2 public bug.

I also don't know why do we need this case:
bug-bind.py --private [id1] --public [id2] # Only tag originate-from-id1 on id2 public bug and make sure id1 is private before the tag.

review: Needs Information
Revision history for this message
Shih-Yuan Lee (fourdollars) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/bug-bind.py b/bug-bind.py
2index c98bbc2..16056b6 100755
3--- a/bug-bind.py
4+++ b/bug-bind.py
5@@ -63,6 +63,29 @@ def link_bugs(public_bugnum, privates, ihv):
6 add_bug_task(pub_bug, hwe_next)
7
8
9+def link_priv_bugs(main_bugnum, privates, ihv):
10+ assert(main_bugnum.isdigit())
11+ login = LaunchpadLogin()
12+ lp = login.lp
13+ main_bug = lp.bugs[main_bugnum]
14+
15+ tag = "X-SWE-Bug: Bug #" + main_bugnum
16+
17+ # Add X-HWE-Bug: tag to description.
18+ for priv in privates:
19+ assert(priv.isdigit())
20+ bug = lp.bugs[priv]
21+
22+ if re.search(tag, bug.description) is None:
23+ # Add the referenced main bug to the private bug, if it's not in already.
24+ bug.description += "\n\n{}\n".format(tag)
25+ bug.lp_save()
26+ else:
27+ log.warning("Bug already linked to main bug " + tag)
28+
29+ add_bug_tags(main_bug, ['originate-from-' + str(bug.id)])
30+
31+
32 def add_bug_task(bug, bug_task):
33 assert(type(bug_task) == lazr.restfulclient.resource.Entry)
34
35@@ -105,6 +128,7 @@ bud-bind -p bugnumber private_bugnumber1 private_bugnumber2"""
36 3. Use bug-bind to bind public and private bug."""
37
38 parser = argparse.ArgumentParser(description=description, epilog=help, formatter_class=argparse.RawDescriptionHelpFormatter)
39+ parser.add_argument('-m', '--main', help='main bug for private bugs')
40 parser.add_argument('-p', '--public', help='The public bug number')
41 parser.add_argument('-i', '--ihv', help='Launchpad project name for IHV\nExpecting "swe", "hwe", "intel", "amd", "nvidia", "lsi", "emulex"', default='swe')
42 parser.add_argument('-v', '--vebose', help='shows debug messages', action='store_true', default=False)
43@@ -118,5 +142,7 @@ bud-bind -p bugnumber private_bugnumber1 private_bugnumber2"""
44 raise Exception('Expecting "swe", "hwe", "intel", "amd", "nvidia", "lsi", "emulex" for ihv')
45 if len(private_bugs) == 0:
46 parser.error("must provide private bug numbers.")
47-
48- link_bugs(args.public, private_bugs, args.ihv)
49+ if args.main:
50+ link_priv_bugs(args.main, private_bugs, args.ihv)
51+ else:
52+ link_bugs(args.public, private_bugs, args.ihv)

Subscribers

People subscribed via source and target branches