Remove variables and libraries for groupbasedpolicy
[integration/test.git] / tools / distchanges / distcompare.py
1 import argparse
2 from changes import Changes
3
4 # assumes that the new/current and older distributions are unzipped in /tmp/distro_new and
5 # /tmp_distro_old respectively
6
7
8 class DistCompare(object):
9     def __init__(self, remote_url):
10
11         self.remote_url = remote_url
12
13     @staticmethod
14     def get_project_names():
15         # TODO: when autorelease starts publishing the dependencies.log artifact, this function (or the consumer
16         # of this tool) can take the latest dependencies.log from jenkins lastSuccessfulArtifacts and put it
17         # in /tmp/ For now the functionality to read the projects from that file are commented.
18         """
19         projects = []
20         with open("/tmp/dependencies.log") as dep_file:
21             for line in dep_file:
22                 if line != "\n":
23                     projects.append(line.split(":")[0])
24
25         return projects
26         """
27         # this hard coded list of projects was taken from Oxygen dependencies.log - late January 2018
28         return [
29             "integration/distribution",
30             "mdsal",
31             "alto",
32             "sfc",
33             "bier",
34             "serviceutils",
35             "usc",
36             "ovsdb",
37             "lispflowmapping",
38             "snmp4sdn",
39             "aaa",
40             "honeycomb/vbd",
41             "openflowplugin",
42             "of-config",
43             "daexim",
44             "dluxapps",
45             "coe",
46             "packetcable",
47             "yangtools",
48             "infrautils",
49             "neutron",
50             "snmp",
51             "bgpcep",
52             "nemo",
53             "netconf",
54             "tsdr",
55             "sxp",
56             "jsonrpc",
57             "p4plugin",
58             "odlparent",
59             "l2switch",
60             "dlux",
61             "controller",
62         ]
63
64     def run_cmd(self):
65         query_limit = 100
66         num_to_display = 50
67         branch = "master"
68         project_names = self.get_project_names()
69         extracted_distro_locations = {
70             "new": "/tmp/distro_new",
71             "old": "/tmp/distro_old",
72         }
73
74         new_changes = Changes(
75             branch,
76             extracted_distro_locations["new"],
77             num_to_display,
78             query_limit,
79             project_names,
80             self.remote_url,
81         )
82
83         new_projects = new_changes.run_cmd()
84         new_changes.pretty_print_projects(new_projects)
85
86         old_changes = Changes(
87             branch,
88             extracted_distro_locations["old"],
89             num_to_display,
90             query_limit,
91             project_names,
92             self.remote_url,
93         )
94
95         old_projects = old_changes.run_cmd()
96         old_changes.pretty_print_projects(old_projects)
97
98         patchset_diff = []
99         print("\nPatch differences:\n------------------")
100         for project_name, values in new_projects.items():
101             new_gerrits = values["includes"]
102             for gerrit in new_gerrits:
103                 if gerrit not in old_projects[project_name]["includes"]:
104                     patchset_diff.append(gerrit)
105                     print(
106                         "{:<20}{}\t{}".format(
107                             project_name, gerrit["url"], gerrit["subject"]
108                         )
109                     )
110
111         print("\n%s different patches between the two distros." % len(patchset_diff))
112
113
114 def main():
115
116     parser = argparse.ArgumentParser(
117         description="Returns the list of patches found in the unzipped distribution at "
118         "/tmp/distro_new that are not found in the distribution at "
119         "/tmp/distro_old. This should result in a listing of what new changes "
120         "were made between the two distributions."
121     )
122     parser.add_argument(
123         "-r",
124         "--remote",
125         dest="remote_url",
126         default=Changes.REMOTE_URL,
127         help="git remote url to use for gerrit",
128     )
129     options = parser.parse_args()
130
131     distc = DistCompare(options.remote_url)
132     distc.run_cmd()
133
134
135 if __name__ == "__main__":
136     main()