From: Aaron Bentley Date: Wed, 9 Mar 2005 20:28:18 +0000 (+0000) Subject: Implemented set-root command X-Git-Tag: 1.0.0~381 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=53f475a31b97cb3e3a84ae099565cb1858af5014;p=be.git Implemented set-root command --- diff --git a/be b/be index 47eec40..d88c43e 100755 --- a/be +++ b/be @@ -7,7 +7,7 @@ be comment: append a comment to a bug be set-root: assign the root directory for bug tracking """ from libbe.cmdutil import * -from libbe.bugdir import tree_root +from libbe.bugdir import tree_root, create_bug_dir from libbe import names import sys import os @@ -34,6 +34,10 @@ def list_bugs(args): target = " target: %s" % target print "id: %s severity: %s%s\n%s\n" % (unique_name(bug, bugs), bug.severity, target, bug.summary) +def set_root(args): + if len(args) != 1: + raise UserError("Please supply a directory path") + create_bug_dir(args[0]) def new_bug(args): if len(args) != 1: @@ -62,6 +66,7 @@ else: try: cmd = { "list": list_bugs, + "set-root": set_root, "new": new_bug, "close": close_bug, "open": open_bug, diff --git a/libbe/bugdir.py b/libbe/bugdir.py index 5e1d409..7fc1eda 100644 --- a/libbe/bugdir.py +++ b/libbe/bugdir.py @@ -26,6 +26,14 @@ def tree_root(dir): def test_version(path): assert (file(path, "rb").read() == "Bugs Everywhere Tree 0 0\n") +def create_bug_dir(path): + root = os.path.join(path, ".be") + os.mkdir(root) + os.mkdir(os.path.join(root, "bugs")) + f = file(os.path.join(root, "version"), "wb") + f.write("Bugs Everywhere Tree 0 0\n") + return BugDir(path) + class BugDir: def __init__(self, dir): self.dir = dir