def getRevision(path=None): """Returns the last revision/hash of the svn.""" return executeCommand( "svnversion", "Could not figure out SVN revision. Is there a valid SVN repository?", path=path)
def getInfo(path=None): textResult = executeCommand( "svn info", "Could not figure out SVN info. Is there a valid SVN repository?", path=path ) parsedResult = yaml.load(textResult) return parsedResult
def test_testem(profile, target="source", browsers=None, root="../"): """ Automatically executes tests using Testem. Using a comma separated list of `browsers` one can define which browsers to use. By default Testem will use all browsers it finds on the system. The list could be printed out on screen using `testem launchers`. The `root` needs to be the folder where the testem files should be executed in which needs to be the folder which contains all the other relevant files for the project. Typically when you use the convention of a `test` folder inside your real project just use the default `..` which points to the "real" project's root folder. """ # Add parameter for browsers - otherwise auto-detected browsers = "-l %s" % browsers if browsers else "" Console.info("") Console.info("Running Testem based test suite...") # We execute the testem command in the root of the project retval = executeCommand("testem ci " + browsers + " -f test/testem-" + target + ".json", path=root, wrapOutput=False) Console.info("") return retval
def getInfo(path=None): textResult = executeCommand( "svn info", "Could not figure out SVN info. Is there a valid SVN repository?", path=path) parsedResult = yaml.load(textResult) return parsedResult
def distcleanRepository(): """ Cleans git repository from untracked files. Ignores the files listed in ".gitignore". """ return executeCommand(["git", "clean", "-d", "-f", "-x"], "Could not distclean GIT repository!")
def test_node(profile): """Automatically executes tests using NodeJS""" Console.info("") Console.info("Running NodeJS based test suite...") retval = executeCommand("node node.js", path=profile.getDestinationPath(), wrapOutput=False) Console.info("") return retval
def test_node(): """Automatically executes tests using NodeJS""" prefix = session.getCurrentPrefix() Console.info("") Console.info("Running NodeJS based test suite...") retval = executeCommand("node node.js", path=prefix, wrapOutput=False) Console.info("") return retval
def test_testem(browsers=None, root=".."): """ Automatically executes tests using Testem. Using a comma separated list of `browsers` one can define which browsers to use. By default Testem will use all browsers it finds on the system. The list could be printed out on screen using `testem launchers`. The `root` needs to be the folder where the testem files should be executed in which needs to be the folder which contains all the other relevant files for the project. Typically when you use the convention of a `test` folder inside your real project just use the default `..` which points to the "real" project's root folder. """ prefix = session.getCurrentPrefix() # We need to use a full temporary directory and even a named temporary file # is not being guaranteed able to be accessed a second time. configDir = tempfile.TemporaryDirectory() pagePath = os.path.join("test", prefix, "index.html") testemConfig = open(os.path.join(configDir.name, "testem.json"), "w") testemConfig.write('{"framework": "custom", "test_page" : "' + pagePath + '"}') testemConfig.close() # Add parameter for browsers - otherwise auto-detected if browsers: browsers = "-l %s" % browsers else: browsers = "" Console.info("") Console.info("Running Testem based test suite...") # We execute the testem command in the root of the project retval = executeCommand("testem ci " + browsers + " -f " + testemConfig.name, path=root, wrapOutput=False) Console.info("") return retval
def getBranch(path=None): """Returns the name of the git branch.""" return executeCommand("git rev-parse --abbrev-ref HEAD", "Could not figure out git branch. Is there a valid Git repository?", path=path)
def cleanRepository(): """Cleans git repository from untracked files.""" return executeCommand(["git", "clean", "-d", "-f"], "Could not clean GIT repository!")
def npmInstall(pkgs): """ Installs all packages via npm """ cmd = generatePackageList(pkgs) if len(cmd) > 0: Console.info("Installing node packages : %s" % pkgs) executeCommand("npm install %s" % " ".join(cmd), "Installing nodejs modules failed!")
def update(url, version, path, update=True, submodules=True): """Clones the given repository URL (optionally with overriding/update features)""" # Prepend git+ so that user knows that we identified the URL as git repository if not url.startswith("git+"): url = "git+%s" % url old = os.getcwd() if os.path.exists(path) and os.path.exists(os.path.join(path, ".git")): if not os.path.exists(os.path.join(path, ".git", "HEAD")): Console.error("Invalid git clone. Cleaning up...") shutil.rmtree(path) else: os.chdir(path) revision = executeCommand(["git", "rev-parse", "HEAD"], "Could not detect current revision") if update and (version == "master" or "refs/heads/" in version): if update: Console.info("Updating %s", Console.colorize("%s @ " % url, "bold") + Console.colorize(version, "magenta")) Console.indent() try: executeCommand(["git", "fetch", "-q", "--depth", "1", "origin", version], "Could not fetch updated revision!") executeCommand(["git", "reset", "-q", "--hard", "FETCH_HEAD"], "Could not update checkout!") newRevision = executeCommand(["git", "rev-parse", "HEAD"], "Could not detect current revision") if revision != newRevision: Console.info("Updated from %s to %s", revision[:10], newRevision[:10]) revision = newRevision if submodules and os.path.exists(".gitmodules"): Console.info("Updating sub modules (this might take some time)...") executeCommand("git submodule update --recursive", "Could not initialize sub modules") except Exception: Console.error("Error during git transaction! Could not update clone.") Console.error("Please verify that the host is reachable or disable automatic branch updates.") Console.outdent() os.chdir(old) return except KeyboardInterrupt: print() Console.error("Git transaction was aborted by user!") Console.outdent() os.chdir(old) return Console.outdent() else: Console.debug("Updates disabled") else: Console.debug("Using existing clone") os.chdir(old) return revision Console.info("Cloning %s", Console.colorize("%s @ " % url, "bold") + Console.colorize(version, "magenta")) Console.indent() os.makedirs(path) os.chdir(path) try: # cut of "git+" prefix remoteurl = url[4:] executeCommand(["git", "init", "."], "Could not initialize GIT repository!") executeCommand(["git", "remote", "add", "origin", remoteurl], "Could not register remote repository!") executeCommand(["git", "fetch", "-q", "--depth", "1", "origin", version], "Could not fetch revision!") executeCommand(["git", "reset", "-q", "--hard", "FETCH_HEAD"], "Could not update checkout!") revision = executeCommand(["git", "rev-parse", "HEAD"], "Could not detect current revision") if submodules and os.path.exists(".gitmodules"): Console.info("Updating sub modules (this might take some time)...") executeCommand("git submodule update --init --recursive", "Could not initialize sub modules") except Exception: Console.error("Error during git transaction! Intitial clone required for continuing!") Console.error("Please verify that the host is reachable.") Console.error("Cleaning up...") os.chdir(old) shutil.rmtree(path) Console.outdent() return except KeyboardInterrupt: print() Console.error("Git transaction was aborted by user!") Console.error("Cleaning up...") os.chdir(old) shutil.rmtree(path) Console.outdent() return os.chdir(old) Console.outdent() return revision
def getRevision(path=None): """Returns the last revision/hash of the svn.""" return executeCommand("svnversion", "Could not figure out SVN revision. Is there a valid SVN repository?", path=path)
def getBranch(path=None): """Returns the name of the git branch""" return executeCommand("git rev-parse --abbrev-ref HEAD", "Could not figure out git branch. Is there a valid Git repository?", path=path)
def getShortRevision(path=None): """Returns the last shortened revision/hash of the git repository""" return executeCommand("git rev-parse --short HEAD", "Could not figure out git revision. Is there a valid Git repository?", path=path)
def getShortRevision(path=None): """Returns the last shortened revision/hash of the git repository.""" return executeCommand("git rev-parse --short HEAD", "Could not figure out git revision. Is there a valid Git repository?", path=path)