aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--SBoTools/plugin.py57
1 files changed, 57 insertions, 0 deletions
diff --git a/SBoTools/plugin.py b/SBoTools/plugin.py
index 7ffd824..9e03ad7 100644
--- a/SBoTools/plugin.py
+++ b/SBoTools/plugin.py
@@ -263,4 +263,61 @@ class SBoTools(callbacks.Plugin):
sbomaint = thread(wrap(sbomaint, [many('somethingWithoutSpaces')]))
+ def getDependees(self, rflag, buildid, db):
+ retlist = []
+ cursor = db.cursor()
+ cursor.execute("select c.name, b.name, build_id from builds b, categories c, deps d where b.category=c.id and b.id=d.build_id and d.depends_on=?", (buildid,))
+ result = cursor.fetchall()
+ for (cat, name, bid) in result:
+ retlist.append(ircutils.bold(cat + "/" + name))
+ if(rflag):
+ sublist = self.getDependees(rflag, bid, db)
+ if(len(sublist) > 0):
+ retlist.append("[")
+ retlist.extend(sublist)
+ retlist.append("]")
+ return retlist
+
+ def sborevdep(self, irc, msg, args, rflag, catbuild):
+ """ [-r] <build>
+
+ Show builds that depend on <build>. With -r, show builds that
+ depend on each result, recursively.
+ """
+
+ category = None
+ build = None
+
+ t = catbuild.split('/',1)
+ if(len(t) == 1):
+ build = catbuild
+ else:
+ category = self.getCategory(t[0])
+ if(category is None):
+ irc.error("invalid category '" + t[0] + "'", Raise=True)
+ build = t[1]
+
+ db = self.InitDB();
+ cursor = db.cursor()
+ sql = "select b.id from builds b"
+ if(category is None):
+ sql += " where "
+ else:
+ sql += ", categories c where c.id=" + str(category) + " and b.category=c.id and "
+ sql += "b.name=?"
+ cursor.execute(sql, (build,))
+
+ result = cursor.fetchall()
+ if(len(result) == 0):
+ irc.reply("no such build: " + catbuild)
+ return
+
+ lines = self.getDependees(rflag, result[0][0], db)
+ if(len(lines) == 0):
+ irc.reply("nothing depends on " + catbuild)
+ else:
+ irc.replies(lines, joiner=' ')
+
+ sborevdep = thread(wrap(sborevdep, [optional(('literal', ['-r'])), 'somethingWithoutSpaces']))
+
Class = SBoTools