How to use find_vcs_root method in molecule

Best Python code snippet using molecule_python

release_vcs.py

Source:release_vcs.py Github

copy

Full Screen

...23 return cls(path)24 classes_by_level = {}25 for vcs_name in vcs_types:26 cls = plugin_manager.get_plugin_class('release_vcs', vcs_name)27 result = cls.find_vcs_root(path)28 if not result:29 continue30 vcs_path, levels_up = result31 classes_by_level.setdefault(levels_up, []).append((cls, vcs_path))32 if not classes_by_level:33 raise ReleaseVCSError(34 "No version control system for package "35 "releasing is associated with the path %s" % path36 )37 # it's ok to have multiple results, as long as there is only one at the38 # "closest" directory up from this dir - ie, if we start at:39 # /blah/foo/pkg_root40 # and these dirs exist:41 # /blah/.hg42 # /blah/foo/.git43 # ...then this is ok, because /blah/foo/.git is "closer" to the original44 # dir, and will be picked. However, if these two directories exist:45 # /blah/foo/.git46 # /blah/foo/.hg47 # ...then we error, because we can't decide which to use48 lowest_level = sorted(classes_by_level)[0]49 clss = classes_by_level[lowest_level]50 if len(clss) > 1:51 clss_str = ", ".join(x[0].name() for x in clss)52 raise ReleaseVCSError("Several version control systems are associated "53 "with the path %s: %s. Use rez-release --vcs to "54 "choose." % (path, clss_str))55 else:56 cls, vcs_root = clss[0]57 return cls(pkg_root=path, vcs_root=vcs_root)58class ReleaseVCS(object):59 """A version control system (VCS) used to release Rez packages.60 """61 def __init__(self, pkg_root, vcs_root=None):62 if vcs_root is None:63 result = self.find_vcs_root(pkg_root)64 if not result:65 raise ReleaseVCSError("Could not find %s repository for the "66 "path %s" % (self.name(), pkg_root))67 vcs_root = result[0]68 else:69 assert(self.is_valid_root(vcs_root))70 self.vcs_root = vcs_root71 self.pkg_root = pkg_root72 self.package = get_developer_package(pkg_root)73 self.type_settings = self.package.config.plugins.release_vcs74 self.settings = self.type_settings.get(self.name())75 @classmethod76 def name(cls):77 """Return the name of the VCS type, eg 'git'."""78 raise NotImplementedError79 @classmethod80 def find_executable(cls, name):81 exe = which(name)82 if not exe:83 raise ReleaseVCSError("Couldn't find executable '%s' for VCS '%s'"84 % (name, cls.name()))85 return exe86 @classmethod87 def is_valid_root(cls, path):88 """Return True if the given path is a valid root directory for this89 version control system.90 Note that this is different than whether the path is under the91 control of this type of vcs; to answer that question,92 use find_vcs_root93 """94 raise NotImplementedError95 @classmethod96 def search_parents_for_root(cls):97 """Return True if this vcs type should check parent directories to98 find the root directory99 """100 raise NotImplementedError101 @classmethod102 def find_vcs_root(cls, path):103 """Try to find a version control root directory of this type for the104 given path.105 If successful, returns (vcs_root, levels_up), where vcs_root is the106 path to the version control root directory it found, and levels_up is an107 integer indicating how many parent directories it had to search through108 to find it, where 0 means it was found in the indicated path, 1 means it109 was found in that path's parent, etc. If not sucessful, returns None110 """111 if cls.search_parents_for_root():112 valid_dirs = walk_up_dirs(path)113 else:114 valid_dirs = [path]115 for i, current_path in enumerate(valid_dirs):116 if cls.is_valid_root(current_path):...

Full Screen

Full Screen

kit.py

Source:kit.py Github

copy

Full Screen

...15 @classmethod16 def is_valid_kit_root(cls, path):17 return os.path.isfile(os.path.join(path, ".kit"))18 @classmethod19 def find_vcs_root(cls, path):20 result = super(KitReleaseVCS, cls).find_vcs_root(path)21 if result is not None:22 vcs_path, levels_up = result23 if cls.is_valid_kit_root(path):24 return vcs_path, -1 # pop-up25 else:26 return vcs_path, 9999 # or, back down27 def get_current_revision(self):28 doc = super(KitReleaseVCS, self).get_current_revision()29 if self.is_kit:30 doc["commit"] = self.get_latest_commit()31 return doc32 def get_latest_commit(self):33 args = ["rev-list", "HEAD", "-1"]34 return self.git(*args)[0]...

Full Screen

Full Screen

sublime-fork.py

Source:sublime-fork.py Github

copy

Full Screen

1import sublime2import sublime_plugin3import subprocess4import os5def find_vcs_root(test, dirs=(".git",), default=None):6 import os7 prev, test = None, os.path.abspath(test)8 while prev != test:9 if any(os.path.exists(os.path.join(test, d)) for d in dirs):10 return test11 prev, test = test, os.path.abspath(os.path.join(test, os.pardir))12 return default13def open_fork(path, args):14 args = ["/Applications/Fork.app/Contents/Resources/fork_cli", "--git-dir={}".format(find_vcs_root(path))] + args15 print("open_fork:", args)16 subprocess.Popen(args)17class ForkOpenRepoCommand(sublime_plugin.ApplicationCommand):18 def run(self, paths=None):19 folders = sublime.active_window().folders()20 path = None21 if paths:22 path = paths[0]23 elif folders != []:24 path = folders[0]25 if path:26 open_fork(path, ["open", path])27class ForkViewHistoryCommand(sublime_plugin.ApplicationCommand):28 def run(self, **kwargs):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run molecule automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful