Remove remnants of sfc project
[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             "bier",
33             "serviceutils",
34             "usc",
35             "ovsdb",
36             "lispflowmapping",
37             "snmp4sdn",
38             "aaa",
39             "honeycomb/vbd",
40             "openflowplugin",
41             "of-config",
42             "daexim",
43             "dluxapps",
44             "coe",
45             "packetcable",
46             "yangtools",
47             "infrautils",
48             "neutron",
49             "snmp",
50             "bgpcep",
51             "nemo",
52             "netconf",
53             "tsdr",
54             "sxp",
55             "jsonrpc",
56             "p4plugin",
57             "odlparent",
58             "l2switch",
59             "dlux",
60             "controller",
61         ]
62
63     def run_cmd(self):
64         query_limit = 100
65         num_to_display = 50
66         branch = "master"
67         project_names = self.get_project_names()
68         extracted_distro_locations = {
69             "new": "/tmp/distro_new",
70             "old": "/tmp/distro_old",
71         }
72
73         new_changes = Changes(
74             branch,
75             extracted_distro_locations["new"],
76             num_to_display,
77             query_limit,
78             project_names,
79             self.remote_url,
80         )
81
82         new_projects = new_changes.run_cmd()
83         new_changes.pretty_print_projects(new_projects)
84
85         old_changes = Changes(
86             branch,
87             extracted_distro_locations["old"],
88             num_to_display,
89             query_limit,
90             project_names,
91             self.remote_url,
92         )
93
94         old_projects = old_changes.run_cmd()
95         old_changes.pretty_print_projects(old_projects)
96
97         patchset_diff = []
98         print("\nPatch differences:\n------------------")
99         for project_name, values in new_projects.items():
100             new_gerrits = values["includes"]
101             for gerrit in new_gerrits:
102                 if gerrit not in old_projects[project_name]["includes"]:
103                     patchset_diff.append(gerrit)
104                     print(
105                         "{:<20}{}\t{}".format(
106                             project_name, gerrit["url"], gerrit["subject"]
107                         )
108                     )
109
110         print("\n%s different patches between the two distros." % len(patchset_diff))
111
112
113 def main():
114
115     parser = argparse.ArgumentParser(
116         description="Returns the list of patches found in the unzipped distribution at "
117         "/tmp/distro_new that are not found in the distribution at "
118         "/tmp/distro_old. This should result in a listing of what new changes "
119         "were made between the two distributions."
120     )
121     parser.add_argument(
122         "-r",
123         "--remote",
124         dest="remote_url",
125         default=Changes.REMOTE_URL,
126         help="git remote url to use for gerrit",
127     )
128     options = parser.parse_args()
129
130     distc = DistCompare(options.remote_url)
131     distc.run_cmd()
132
133
134 if __name__ == "__main__":
135     main()