def _rec_update_imports(fips_dir, proj_dir, handled) : """same as _rec_fetch_imports() but for updating the imported projects """ ws_dir = util.get_workspace_dir(fips_dir) proj_name = util.get_project_name_from_dir(proj_dir) if proj_name not in handled : handled.append(proj_name) imports = get_imports(fips_dir, proj_dir) for dep in imports: dep_proj_name = dep if dep not in handled: dep_proj_dir = util.get_project_dir(fips_dir, dep_proj_name) log.colored(log.YELLOW, "=== dependency: '{}':".format(dep_proj_name)) dep_ok = False if os.path.isdir(dep_proj_dir) : # directory did not exist, do a fresh git clone dep = imports[dep_proj_name] git_commit = None if 'rev' not in dep else dep['rev'] if git.has_local_changes(dep_proj_dir) : log.warn(" '{}' has local changes, skipping...".format(dep_proj_dir)) else : log.colored(log.BLUE, " updating '{}'...".format(dep_proj_dir)) git.update(dep_proj_dir) if git_commit: log.colored(log.YELLOW, "=== revision: '{}':".format(git_commit)) dep_ok = git.checkout(dep_proj_dir, git_commit) else: dep_ok = True else : log.warn(" '{}' does not exist, please run 'fips fetch'".format(dep_proj_dir)) # recuse if dep_ok : handled = _rec_update_imports(fips_dir, dep_proj_dir, handled) # done, return the new handled array return handled
def run(fips_dir, proj_dir, args): if len(args) > 0 and args[0] == 'fips': if git.has_local_changes(fips_dir): log.warn(" '{}' has local changes, skipping...".format(fips_dir)) else: log.colored(log.BLUE, " updating '{}'...".format(fips_dir)) git.update(fips_dir) else: if len(args) > 0: proj_name = args[0] proj_dir = util.get_project_dir(fips_dir, proj_name) dep.update_imports(fips_dir, proj_dir)