コード例 #1
0
def test_simple(qisrc_action):
    qisrc_action.create_git_project("foo")
    qisrc_action.create_git_project("bar")
    res = qisrc_action("snapshot")
    snapshot = qisrc.snapshot.Snapshot()
    snapshot.load(res)
    assert snapshot.format_version == 2
コード例 #2
0
def test_with_argument(qisrc_action):
    qisrc_action.create_git_project("foo")
    qisrc_action.create_git_project("bar")
    res = qisrc_action("snapshot", "blah.xml")
    assert res == "blah.xml"
    snapshot = qisrc.snapshot.Snapshot()
    snapshot.load(res)
    assert snapshot.format_version == 2
コード例 #3
0
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)
コード例 #4
0
ファイル: reset.py プロジェクト: Grimy/qibuild
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)
コード例 #5
0
ファイル: test_snapshot.py プロジェクト: hakuturu583/qibuild
def test_generate_load(git_worktree, tmpdir):
    """ Test Generate Load """
    foo_proj = git_worktree.create_git_project("foo")
    foo_git = qisrc.git.Git(foo_proj.path)
    _, foo_ref_expected = foo_git.call("rev-parse", "HEAD", raises=False)
    snapshot_txt = tmpdir.join("snapshot.txt").strpath
    qisrc.snapshot.generate_snapshot(git_worktree, snapshot_txt)
    snapshot = qisrc.snapshot.Snapshot()
    snapshot.load(snapshot_txt)
    _foo_ref = snapshot.refs["foo"]
    # Make a commit and an other diff
    foo_git.commit("--message", "empty", "--allow-empty")
    qisrc.snapshot.load_snapshot(git_worktree, snapshot_txt)
    _, foo_ref_actual = foo_git.call("rev-parse", "HEAD", raises=False)
    assert foo_ref_actual == foo_ref_expected
コード例 #6
0
ファイル: test_snapshot.py プロジェクト: Mhalla/qibuild
def test_generate_load(git_worktree, tmpdir):
    foo_proj = git_worktree.create_git_project("foo")
    foo_git = qisrc.git.Git(foo_proj.path)
    _, foo_ref_expected = foo_git.call("rev-parse", "HEAD", raises=False)
    snapshot_txt = tmpdir.join("snapshot.txt").strpath
    qisrc.snapshot.generate_snapshot(git_worktree, snapshot_txt)
    snapshot = qisrc.snapshot.Snapshot()
    snapshot.load(snapshot_txt)
    foo_ref = snapshot.refs["foo"]

    # Make a commit and an other diff
    foo_git.commit("--message", "empty", "--allow-empty")

    qisrc.snapshot.load_snapshot(git_worktree, snapshot_txt)
    _, foo_ref_actual = foo_git.call("rev-parse", "HEAD", raises=False)

    assert foo_ref_actual == foo_ref_expected
コード例 #7
0
ファイル: reset.py プロジェクト: Giessen/qibuild
def do(args):
    """Main entry points."""

    git_worktree = qisrc.parsers.get_git_worktree(args)
    git_projects = qisrc.parsers.get_git_projects(git_worktree, args,
                                                  default_all=True)
    snapshot = None
    if args.snapshot:
        snapshot = qisrc.snapshot.Snapshot()
        snapshot.load(args.snapshot)

    errors = list()
    for git_project in git_projects:
        state_project = qisrc.status.check_state(git_project, False)

        ui.info(ui.green, git_project.src, ui.reset, ui.bold,
                state_project.tracking)

        qisrc.status.print_state(state_project, False)

        src = git_project.src
        git = qisrc.git.Git(git_project.path)

        if args.clean:
            ui.info("Remove untracked files and directories.")
            if args.force:
                git.clean("--force", "-d", "-x")

        if not state_project.clean:
            ui.info("Clean local changes.")
            if args.force:
                git.checkout(".")

        if not git_project.default_branch:
            ui.info(git_project.src, "not in any manifest, skipping")
            continue
        branch = git_project.default_branch.name
        if state_project.incorrect_proj or state_project.not_on_a_branch:
            ui.info("Checkout", branch)
            if args.force:
                git.checkout(branch)

        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 = git.get_tracking_branch()

        if args.force:
            ui.info("reset", to_reset)
            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.error(" * ", error)
    sys.exit(1)