Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
name=args.name)
if retcode != 0 and not args.continue_on_error:
print('')
info("Stopping branching, to continue pass '--continue-on-error'")
except CalledProcessError as err:
# No need for a trackback here, a git call probably failed
print_exc(traceback.format_exc())
error(str(err))
retcode = 1
except Exception as err:
# Unhandled exception, print traceback
print_exc(traceback.format_exc())
error(str(err))
retcode = 2
if retcode == 0:
info("Working branch: " + ansi('boldon') + \
str(get_current_branch()) + ansi('reset'))
sys.exit(retcode)
"problem run 'git am --resolved' and then exit the "
"shell using 'exit 0'. <<<", use_prefix=False)
info(" To abort use 'exit 1'", use_prefix=False)
if 'bash' in os.environ['SHELL']:
ret = subprocess.call([
"/bin/bash", "-l", "-c",
"""\
/bin/bash --rcfile <(echo "if [ -f /etc/bashrc ]; then source /etc/bashrc; fi; \
if [ -f ~/.bashrc ]; then source ~/.bashrc; fi;PS1='(bloom)$PS1'") -i"""
])
else:
ret = subprocess.call("$SHELL", shell=True)
if ret != 0:
error("User failed to resolve patch conflicts, exiting.")
sys.exit("'git-bloom-patch import' aborted.")
info("User reports that conflicts have been resolved, continuing.")
# Notify the user
info("Applied {0} patches".format(len(patches)))
finally:
if current_branch:
checkout(current_branch, directory=directory)
if os.path.exists(tmp_dir):
shutil.rmtree(tmp_dir)
def check_git_init():
if get_root() is None:
error("Not in a valid git repository", exit=True)
cmd = 'git show-ref --heads'
result = execute_command(cmd, autofail=False,
silent_error=True)
if result != 0:
info("Freshly initialized git repository detected.")
info("An initial empty commit is going to be made.")
if not maybe_continue():
error("Answered no to continue, exiting.", exit=True)
# Make an initial empty commit
execute_command('git commit --allow-empty -m "Initial commit"', silent=True)
except GithubException:
debug(traceback.format_exc())
debug("Failed to get commit for rosdistro index file: api")
return index_url
_rosdistro_index_commit = data.get('commit', {}).get('sha', None)
if _rosdistro_index_commit is not None:
info("ROS Distro index file associate with commit '{0}'"
.format(_rosdistro_index_commit))
# Also mutate the index_url to use the commit (rather than the moving branch name)
base_info = get_gh_info(index_url)
base_branch = base_info['branch']
rosdistro_index_commit = _rosdistro_index_commit # Copy global into local for substitution
middle = "{org}/{repo}".format(**base_info)
index_url = index_url.replace("{pr.netloc}/{middle}/{base_branch}/".format(**locals()),
"{pr.netloc}/{middle}/{rosdistro_index_commit}/".format(**locals()))
info("New ROS Distro index url: '{0}'".format(index_url))
_rosdistro_index_original_branch = base_branch
else:
debug("Failed to get commit for rosdistro index file: json")
return index_url
def summarize_dependency_mapping(data, deps, build_deps, resolved_deps):
if len(deps) == 0 and len(build_deps) == 0:
return
info("Package '" + data['Package'] + "' has dependencies:")
header = " " + ansi('boldoff') + ansi('ulon') + \
"rosdep key => " + data['OSName'] + ' ' + \
data['Distribution'] + " key" + ansi('reset')
template = " " + ansi('cyanf') + "{0:<20} " + ansi('purplef') + \
"=> " + ansi('cyanf') + "{1}" + ansi('reset')
if len(deps) != 0:
info(ansi('purplef') + "Run Dependencies:" +
ansi('reset'))
info(header)
for key in [d.name for d in deps]:
info(template.format(key, resolved_deps[key]))
if len(build_deps) != 0:
info(ansi('purplef') +
"Build and Build Tool Dependencies:" + ansi('reset'))
info(header)
for key in [d.name for d in build_deps]:
info(template.format(key, resolved_deps[key]))
owner = tokens[0]
repo = tokens[1]
branch = tokens[2]
gh = get_github_interface(quiet=True)
if gh is None:
# Failed to get it with auth, try without auth (may fail)
gh = Github(username=None, auth=None)
try:
data = gh.get_branch(owner, repo, branch)
except GithubException:
debug(traceback.format_exc())
debug("Failed to get commit for rosdistro index file: api")
return index_url
_rosdistro_index_commit = data.get('commit', {}).get('sha', None)
if _rosdistro_index_commit is not None:
info("ROS Distro index file associate with commit '{0}'"
.format(_rosdistro_index_commit))
# Also mutate the index_url to use the commit (rather than the moving branch name)
base_info = get_gh_info(index_url)
base_branch = base_info['branch']
rosdistro_index_commit = _rosdistro_index_commit # Copy global into local for substitution
middle = "{org}/{repo}".format(**base_info)
index_url = index_url.replace("{pr.netloc}/{middle}/{base_branch}/".format(**locals()),
"{pr.netloc}/{middle}/{rosdistro_index_commit}/".format(**locals()))
info("New ROS Distro index url: '{0}'".format(index_url))
_rosdistro_index_original_branch = base_branch
else:
debug("Failed to get commit for rosdistro index file: json")
return index_url