def do(args): """Main entry points.""" git_worktree = qisrc.parsers.get_git_worktree(args) snapshot = None if args.snapshot: snapshot = qisrc.snapshot.Snapshot() snapshot.load(args.snapshot) if snapshot and snapshot.format_version and snapshot.format_version >= 1: reset_manifest(git_worktree, snapshot, ignore_groups=args.ignore_groups) git_projects = qisrc.parsers.get_git_projects(git_worktree, args, default_all=True, use_build_deps=True) errors = list() for i, git_project in enumerate(git_projects): ui.info_count(i, len(git_projects), "Reset", git_project.src) src = git_project.src git = qisrc.git.Git(git_project.path) ok, message = git.require_clean_worktree() if not ok and not args.force: ui.warning(message) errors.append(src) continue if not git_project.default_branch: ui.warning(git_project.src, "not in any manifest, skipping") continue branch = git_project.default_branch.name remote = git_project.default_remote.name git.safe_checkout(branch, remote, force=True) to_reset = None if args.snapshot: to_reset = snapshot.refs.get(src) if not to_reset: ui.warning(src, "not found in the snapshot") continue elif args.tag: to_reset = args.tag else: to_reset = "%s/%s" % (remote, branch) try: qisrc.reset.clever_reset_ref(git_project, to_reset) except: errors.append(src) if not errors: return ui.error("Failed to reset some projects") for error in errors: ui.info(ui.red, " * ", error) sys.exit(1)
def do(args): """Main entry points.""" git_worktree = qisrc.parsers.get_git_worktree(args) snapshot = None if args.snapshot: snapshot = qisrc.snapshot.Snapshot() snapshot.load(args.snapshot) if snapshot and snapshot.format_version and snapshot.format_version >= 1: reset_manifest(git_worktree, snapshot, groups=args.groups) git_projects = qisrc.parsers.get_git_projects(git_worktree, args, default_all=True, use_build_deps=True) errors = list() for i, git_project in enumerate(git_projects): ui.info_count(i, len(git_projects), "Reset", git_project.src) src = git_project.src git = qisrc.git.Git(git_project.path) ok, message = git.require_clean_worktree() if not ok and not args.force: ui.warning(message) errors.append(src) continue git.checkout(".") if not git_project.default_branch: ui.warning(git_project.src, "not in any manifest, skipping") continue branch = git_project.default_branch.name remote = git_project.default_remote.name git.safe_checkout(branch, remote, force=True) to_reset = None if args.snapshot: to_reset = snapshot.refs.get(src) if not to_reset: ui.warning(src, "not found in the snapshot") continue elif args.tag: to_reset = args.tag else: to_reset = "%s/%s" % (remote, branch) try: qisrc.reset.clever_reset_ref(git_project, to_reset) except: errors.append(src) if not errors: return ui.error("Failed to reset some projects") for error in errors: ui.info(ui.red, " * ", error) sys.exit(1)
def _safe_checkout(self, project, branch, force=False): """ Helper for self.checkout """ git = qisrc.git.Git(project.path) current_branch = git.get_current_branch() if not current_branch: return False, "not on any branch, skipping" clean, error = git.require_clean_worktree() if not clean and not force: return False, error checkout_args = [branch] if force: checkout_args.append("--force") rc, out = git.checkout(*checkout_args, raises=False) if rc != 0: return False, "Checkout failed " + out return True, None
def main(): parser = argparse.ArgumentParser() parser.add_argument("version") args = parser.parse_args() version = args.version this_dir = os.path.dirname(__file__) qibuild_root = os.path.join(this_dir, "..") git = qisrc.git.Git(qibuild_root) ok, message = git.require_clean_worktree() if not ok: raise Exception(message) for filename in FILES_TO_PATCH: full_path = os.path.join(qibuild_root, filename) fix_version_for_file(full_path, "next", version) git.commit("--all", "-m", "qibuild %s" % version) git.call("tag", "v" + version) for filename in FILES_TO_PATCH: full_path = os.path.join(qibuild_root, filename) fix_version_for_file(filename, version, "next") git.commit("--all", "-m", "start next development") print "All OK feel free to push"