Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_repository_info(self):
"""Return repository information for the current working tree.
Returns:
rbtools.clients.RepositoryInfo:
The repository info structure.
"""
if not check_install(['bzr', 'help']):
logging.debug('Unable to execute "bzr help": skipping Bazaar')
return None
bzr_info = execute(['bzr', 'info'], ignore_errors=True)
if 'ERROR: Not a branch:' in bzr_info:
# This is not a branch:
repository_info = None
else:
# This is a branch, let's get its attributes:
branch_match = re.search(self.BRANCH_REGEX, bzr_info, re.MULTILINE)
path = branch_match.group('branch_path')
if path == '.':
path = os.getcwd()
def get_repository_info(self):
"""Get repository information for the current Git working tree.
This function changes the directory to the top level directory of the
current working tree.
"""
if not check_install(['git', '--help']):
# CreateProcess (launched via subprocess, used by check_install)
# does not automatically append .cmd for things it finds in PATH.
# If we're on Windows, and this works, save it for further use.
if (sys.platform.startswith('win') and
check_install(['git.cmd', '--help'])):
self.git = 'git.cmd'
else:
logging.debug('Unable to execute "git --help" or "git.cmd '
'--help": skipping Git')
return None
git_dir = execute([self.git, "rev-parse", "--git-dir"],
ignore_errors=True).rstrip("\n")
if git_dir.startswith("fatal:") or not os.path.isdir(git_dir):
return None
def get_repository_info(self):
"""Return repository information for the current SVN working tree.
Returns:
rbtools.clients.RepositoryInfo:
The repository info structure.
"""
if self._svn_repository_info_cache:
return self._svn_repository_info_cache
if not check_install(['svn', 'help']):
logging.debug('Unable to execute "svn help": skipping SVN')
return None
# Get the SVN repository path (either via a working copy or
# a supplied URI)
svn_info_params = ['info']
if getattr(self.options, 'repository_url', None):
svn_info_params.append(self.options.repository_url)
data = self._run_svn(svn_info_params, ignore_errors=True,
log_output_on_error=False)
m = re.search('^Repository Root: (.+)$', data, re.M)
if not m:
return None
def get_repository_info(self):
"""Return repository information for the current working tree.
Returns:
rbtools.clients.RepositoryInfo:
The repository info structure.
"""
if not check_install(['cm', 'version']):
logging.debug('Unable to execute "cm version": skipping Plastic')
return None
# Get the workspace directory, so we can strip it from the diff output
self.workspacedir = execute(['cm', 'gwp', '.', '--format={1}'],
split_lines=False,
ignore_errors=True).strip()
logging.debug('Workspace is %s', self.workspacedir)
# Get the repository that the current directory is from
split = execute(['cm', 'ls', self.workspacedir, '--format={8}'],
split_lines=True, ignore_errors=True)
# remove blank lines
split = [x for x in split if x]
def get_repository_info(self):
"""Return information on the ClearCase repository.
This will first check if the cleartool command is installed and in the
path, and that the current working directory is inside of the view.
Returns:
ClearCaseRepositoryInfo:
The repository info structure.
"""
if not check_install(['cleartool', 'help']):
logging.debug('Unable to execute "cleartool help": skipping '
'ClearCase')
return None
viewname = execute(['cleartool', 'pwv', '-short']).strip()
if viewname.startswith('** NONE'):
return None
# Now that we know it's ClearCase, make sure we have GNU diff
# installed, and error out if we don't.
check_gnu_diff()
property_lines = execute(
['cleartool', 'lsview', '-full', '-properties', '-cview'],
split_lines=True)
for line in property_lines:
# First check in the system path. If that doesn't work, look in the
# two standard install locations.
tf_locations.extend([
'tf.cmd',
(r'%programfiles(x86)%\Microsoft Visual Studio 12.0\Common7'
r'\IDE\tf.cmd'),
(r'%programfiles%\Microsoft Team Foundation Server 12.0\Tools'
r'\tf.cmd'),
])
else:
tf_locations.append('tf')
for location in tf_locations:
location = os.path.expandvars(location)
if check_install([location, 'help']):
self.tf = location
break
If the user has :command:`gpg` installed on their system, use that to
check that the package was signed. Otherwise, check the sha256sum.
Args:
url (unicode):
The URL that the file came from.
zip_filename (unicode):
The filename of the downloaded copy.
Raises:
rbtools.commands.CommandError:
The authenticity of the file could not be verified.
"""
if check_install('gpg'):
execute(['gpg', '--recv-keys', '4ED1F993'])
sig_filename = self.download_file('%s.asc' % url)
try:
retcode, output, errors = execute(
['gpg', '--verify', sig_filename, zip_filename],
with_errors=False, ignore_errors=True,
return_error_code=True, return_errors=True)
if retcode == 0:
logging.debug('Verified file signature')
else:
raise CommandError(
'Unable to verify authenticity of file downloaded '
'from %s:\n%s' % (url, errors))
finally: