• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mozilla / relman-auto-nag / #4752

22 Sep 2023 11:51PM CUT coverage: 22.101% (+0.1%) from 22.003%
#4752

push

coveralls-python

suhaibmujahid
[copy_duplicate_info] Drop disabled code

716 of 3554 branches covered (0.0%)

5 of 5 new or added lines in 1 file covered. (100.0%)

1925 of 8710 relevant lines covered (22.1%)

0.22 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/bugbot/rules/copy_duplicate_info.py
1
# This Source Code Form is subject to the terms of the Mozilla Public
2
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
3
# You can obtain one at http://mozilla.org/MPL/2.0/.
4

5
from libmozdata.bugzilla import Bugzilla
×
6

7
from bugbot import utils
×
8
from bugbot.bzcleaner import BzCleaner
×
9

10

11
class CopyDuplicateInfo(BzCleaner):
×
12
    def __init__(self):
×
13
        super(CopyDuplicateInfo, self).__init__()
×
14
        self.autofix_data = {}
×
15

16
    def description(self):
×
17
        return "Bugs which are DUPLICATE and some info haven't been moved"
×
18

19
    def set_autofix(self, bugs, dups, signatures):
×
20
        for bugid, missed_sgns in signatures.items():
×
21
            sgns = dups[bugid]["signature"]
×
22
            sgns = utils.add_signatures(sgns, missed_sgns)
×
23
            self.autofix_data[bugid] = {
×
24
                "cf_crash_signature": sgns,
25
                "comment": {"body": "Copying crash signatures from duplicate bugs."},
26
            }
27

28
    def get_autofix_change(self):
×
29
        return self.autofix_data
×
30

31
    def handle_bug(self, bug, data):
×
32
        bugid = str(bug["id"])
×
33
        data[bugid] = {
×
34
            "id": bugid,
35
            "summary": self.get_summary(bug),
36
            "signature": bug.get("cf_crash_signature", ""),
37
            "dupe": str(bug["dupe_of"]),
38
            "version": bug["version"],
39
            "is_private": bool(bug["groups"]),
40
        }
41
        return bug
×
42

43
    def get_dups(self, bugs):
×
44
        bugids = [info["dupe"] for info in bugs.values()]
×
45
        data = {}
×
46

47
        Bugzilla(
×
48
            bugids=bugids,
49
            include_fields=[
50
                "cf_crash_signature",
51
                "dupe_of",
52
                "id",
53
                "summary",
54
                "groups",
55
                "version",
56
            ],
57
            bughandler=self.handle_bug,
58
            bugdata=data,
59
        ).get_data().wait()
60

61
        return data
×
62

63
    def compare(self, bugs, dups):
×
64
        # each bug in bugs is the dup of one in dups
65
        # so the characteristics of this bug should be in the dup
66
        signatures = {}
×
67
        for bugid, info in bugs.items():
×
68
            dupid = info["dupe"]
×
69
            if dupid not in dups:
×
70
                # the bug is unaccessible (sec bug for example)
71
                continue
×
72

73
            dup = dups[dupid]
×
74
            if info["is_private"] and not dup["is_private"]:
×
75
                # We avoid copying signatures from private to public bugs
76
                continue
×
77

78
            bs = utils.get_signatures(info["signature"])
×
79
            ds = utils.get_signatures(dup["signature"])
×
80
            if not bs.issubset(ds):
×
81
                signatures[dupid] = bs - ds
×
82

83
        return signatures
×
84

85
    def get_bz_params(self, date):
×
86
        start_date, end_date = self.get_dates(date)
×
87
        fields = ["cf_crash_signature", "dupe_of", "version", "groups"]
×
88
        params = {
×
89
            "include_fields": fields,
90
            "resolution": "DUPLICATE",
91
            "f1": "resolution",
92
            "o1": "changedafter",
93
            "v1": start_date,
94
        }
95

96
        return params
×
97

98
    def get_bugs(self, date="today", bug_ids=[]):
×
99
        bugs = super(CopyDuplicateInfo, self).get_bugs(date=date, bug_ids=bug_ids)
×
100
        dups = self.get_dups(bugs)
×
101
        signatures = self.compare(bugs, dups)
×
102

103
        self.set_autofix(bugs, dups, signatures)
×
104

105
        return {bugid: dups[bugid] for bugid in signatures}
×
106

107

108
if __name__ == "__main__":
×
109
    CopyDuplicateInfo().run()
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc