本文整理汇总了Python中pants.scm.git.Git.detect_worktree方法的典型用法代码示例。如果您正苦于以下问题:Python Git.detect_worktree方法的具体用法?Python Git.detect_worktree怎么用?Python Git.detect_worktree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pants.scm.git.Git
的用法示例。
在下文中一共展示了Git.detect_worktree方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_detect_worktree_failing_git
# 需要导入模块: from pants.scm.git import Git [as 别名]
# 或者: from pants.scm.git.Git import detect_worktree [as 别名]
def test_detect_worktree_failing_git(self):
with self.executable_git() as git:
with open(git, 'w') as fp:
fp.write('#!/bin/sh\n')
fp.write('exit 1')
self.assertIsNone(Git.detect_worktree())
self.assertIsNone(Git.detect_worktree(git))
示例2: test_detect_worktree_working_git
# 需要导入模块: from pants.scm.git import Git [as 别名]
# 或者: from pants.scm.git.Git import detect_worktree [as 别名]
def test_detect_worktree_working_git(self):
expected_worktree_dir = '/a/fake/worktree/dir'
with self.executable_git() as git:
with open(git, 'w') as fp:
fp.write('#!/bin/sh\n')
fp.write('echo ' + expected_worktree_dir)
self.assertEqual(expected_worktree_dir, Git.detect_worktree())
self.assertEqual(expected_worktree_dir, Git.detect_worktree(binary=git))
示例3: test_detect_worktree_somewhere_else
# 需要导入模块: from pants.scm.git import Git [as 别名]
# 或者: from pants.scm.git.Git import detect_worktree [as 别名]
def test_detect_worktree_somewhere_else(self):
with temporary_dir() as somewhere_else:
with pushd(somewhere_else):
loc = Git.detect_worktree(dir=somewhere_else)
self.assertEquals(None, loc)
subprocess.check_call(['git', 'init'])
loc = Git.detect_worktree(dir=somewhere_else)
self.assertEquals(os.path.realpath(somewhere_else), loc)
示例4: worktree_relative_to
# 需要导入模块: from pants.scm.git import Git [as 别名]
# 或者: from pants.scm.git.Git import detect_worktree [as 别名]
def worktree_relative_to(some_dir, expected):
# Given a directory relative to the worktree, tests that the worktree is detected as 'expected'.
subdir = os.path.join(clone, some_dir)
if not os.path.isdir(subdir):
os.mkdir(subdir)
actual = Git.detect_worktree(subdir=subdir)
self.assertEqual(expected, actual)
示例5: project_template
# 需要导入模块: from pants.scm.git import Git [as 别名]
# 或者: from pants.scm.git.Git import detect_worktree [as 别名]
def project_template(self):
target_levels = {Revision.lenient(platform['target_level'])
for platform in self.blob['jvm_platforms']['platforms'].values()}
lang_level = max(target_levels) if target_levels else Revision(1, 8)
configured_project = TemplateData(
root_dir=get_buildroot(),
outdir=self.output_directory,
git_root=Git.detect_worktree(),
modules=self.module_templates_by_filename.values(),
java=TemplateData(
encoding=self.java_encoding,
maximum_heap_size=self.java_maximum_heap_size,
jdk='{0}.{1}'.format(*lang_level.components[:2]),
language_level='JDK_{0}_{1}'.format(*lang_level.components[:2]),
),
resource_extensions=[],
scala=None,
checkstyle_classpath=';'.join([]),
debug_port=self.debug_port,
annotation_processing=self.annotation_processing_template,
extra_components=[],
junit_tests=self._junit_tests_config(),
global_junit_vm_parameters=' '.join(self.global_junit_jvm_options),
)
return configured_project
示例6: __call__
# 需要导入模块: from pants.scm.git import Git [as 别名]
# 或者: from pants.scm.git.Git import detect_worktree [as 别名]
def __call__(self, manifest_entries=None):
"""Returns a dict suitable for passing to 'manifest_entries' in a 'jvm_binary() definition"""
manifest_entries = manifest_entries or {}
buildroot = get_buildroot()
worktree = Git.detect_worktree(subdir=os.path.join(buildroot,
self._parse_context.rel_path))
if worktree:
git = Git(worktree=worktree)
manifest_entries['Implementation-Version'] = git.commit_id
manifest_entries['Built-By'] = pwd.getpwuid(os.getuid()).pw_name
return manifest_entries
示例7: worktree_relative_to
# 需要导入模块: from pants.scm.git import Git [as 别名]
# 或者: from pants.scm.git.Git import detect_worktree [as 别名]
def worktree_relative_to(cwd, expected):
"""Given a cwd relative to the worktree, tests that the worktree is detected as 'expected'."""
orig_cwd = os.getcwd()
try:
abs_cwd = os.path.join(clone, cwd)
if not os.path.isdir(abs_cwd):
os.mkdir(abs_cwd)
os.chdir(abs_cwd)
actual = Git.detect_worktree()
self.assertEqual(expected, actual)
finally:
os.chdir(orig_cwd)
示例8: get_scm
# 需要导入模块: from pants.scm.git import Git [as 别名]
# 或者: from pants.scm.git.Git import detect_worktree [as 别名]
def get_scm():
"""Returns the pants Scm if any."""
# TODO(John Sirois): Extract a module/class to carry the bootstrap logic.
global _SCM
if not _SCM:
from pants.scm.git import Git
# We know about git, so attempt an auto-configure
worktree = Git.detect_worktree()
if worktree and os.path.isdir(worktree):
git = Git(worktree=worktree)
try:
logger.info('Detected git repository at {} on branch {}'.format(worktree, git.branch_name))
set_scm(git)
except git.LocalException as e:
logger.info('Failed to load git repository at {}: {}'.format(worktree, e))
return _SCM
示例9: generate_project
# 需要导入模块: from pants.scm.git import Git [as 别名]
# 或者: from pants.scm.git.Git import detect_worktree [as 别名]
def generate_project(self, project):
def create_content_root(source_set):
root_relative_path = os.path.join(source_set.source_base, source_set.path) \
if source_set.path else source_set.source_base
if self.get_options().infer_test_from_siblings:
is_test = IdeaGen._sibling_is_test(source_set)
else:
is_test = source_set.is_test
if source_set.resources_only:
if source_set.is_test:
content_type = 'java-test-resource'
else:
content_type = 'java-resource'
else:
content_type = ''
sources = TemplateData(
path=root_relative_path,
package_prefix=source_set.path.replace('/', '.') if source_set.path else None,
is_test=is_test,
content_type=content_type
)
return TemplateData(
path=root_relative_path,
sources=[sources],
exclude_paths=[os.path.join(source_set.source_base, x) for x in source_set.excludes],
)
content_roots = [create_content_root(source_set) for source_set in project.sources]
if project.has_python:
content_roots.extend(create_content_root(source_set) for source_set in project.py_sources)
scala = None
if project.has_scala:
scala = TemplateData(
language_level=self.scala_language_level,
maximum_heap_size=self.scala_maximum_heap_size,
fsc=self.fsc,
compiler_classpath=project.scala_compiler_classpath
)
exclude_folders = []
if self.get_options().exclude_maven_target:
exclude_folders += IdeaGen._maven_targets_excludes(get_buildroot())
exclude_folders += self.get_options().exclude_folders
java_language_level = None
for target in project.targets:
if isinstance(target, JvmTarget):
if java_language_level is None or java_language_level < target.platform.source_level:
java_language_level = target.platform.source_level
if java_language_level is not None:
java_language_level = 'JDK_{0}_{1}'.format(*java_language_level.components[:2])
configured_module = TemplateData(
root_dir=get_buildroot(),
path=self.module_filename,
content_roots=content_roots,
bash=self.bash,
python=project.has_python,
scala=scala,
internal_jars=[cp_entry.jar for cp_entry in project.internal_jars],
internal_source_jars=[cp_entry.source_jar for cp_entry in project.internal_jars
if cp_entry.source_jar],
external_jars=[cp_entry.jar for cp_entry in project.external_jars],
external_javadoc_jars=[cp_entry.javadoc_jar for cp_entry in project.external_jars
if cp_entry.javadoc_jar],
external_source_jars=[cp_entry.source_jar for cp_entry in project.external_jars
if cp_entry.source_jar],
annotation_processing=self.annotation_processing_template,
extra_components=[],
exclude_folders=exclude_folders,
java_language_level=java_language_level,
)
outdir = os.path.abspath(self.intellij_output_dir)
if not os.path.exists(outdir):
os.makedirs(outdir)
configured_project = TemplateData(
root_dir=get_buildroot(),
outdir=outdir,
git_root=Git.detect_worktree(),
modules=[configured_module],
java=TemplateData(
encoding=self.java_encoding,
maximum_heap_size=self.java_maximum_heap_size,
jdk=self.java_jdk,
language_level='JDK_1_{}'.format(self.java_language_level)
),
resource_extensions=list(project.resource_extensions),
scala=scala,
checkstyle_classpath=';'.join(project.checkstyle_classpath),
debug_port=project.debug_port,
annotation_processing=self.annotation_processing_template,
extra_components=[],
#.........这里部分代码省略.........
示例10: test_detect_worktree_invalid_executable_git
# 需要导入模块: from pants.scm.git import Git [as 别名]
# 或者: from pants.scm.git.Git import detect_worktree [as 别名]
def test_detect_worktree_invalid_executable_git(self):
with self.executable_git() as git:
self.assertIsNone(Git.detect_worktree())
self.assertIsNone(Git.detect_worktree(binary=git))
示例11: test_detect_worktree_no_git
# 需要导入模块: from pants.scm.git import Git [as 别名]
# 或者: from pants.scm.git.Git import detect_worktree [as 别名]
def test_detect_worktree_no_git(self):
with self.empty_path():
self.assertIsNone(Git.detect_worktree())