Пример #1
0
def do(args):
    """Main entry point"""
    logger   = qibuild.log.get_logger(__name__)
    qiwt     = qisrc.open_worktree(args.worktree)

    if args.force:
        logger.info("preparing to remove:")
    else:
        logger.info("Build directory that will be removed (use -f to apply):")
    folders = dict()
    for project in qiwt.buildable_projects:
        result = list_build_folder(project.path, args.build_directory, qiwt.root)
        for k, v in result.iteritems():
            if folders.get(k):
                folders[k].extend(v)
            else:
                folders[k] = v
    for k, v in folders.iteritems():
        logger.info(k)
        print " ", ",".join(v)
        # for p in v:
        #     print "  %s" % p

    if args.force:
        logger.info("")
        logger.info("removing:")
        for project in qiwt.buildable_projects:
            cleanup(project.path, args.build_directory, qiwt.root, args.force)
Пример #2
0
def do(args):
    """Main entry point"""
    src = args.src
    src = qibuild.sh.to_native_path(src)
    if not os.path.exists(src):
        raise Exception("%s does not exists" % src)
    worktree = qisrc.open_worktree(args.worktree)
    worktree.add_project(src)
Пример #3
0
def do(args):
    """ Main method """
    qiwt  = qisrc.open_worktree(args.worktree)
    regex = args.pattern
    if args.pattern:
        regex = re.compile(regex)
    print "Projects in :", qiwt.root
    print
    for project in qiwt.projects:
        if not regex or regex.search(project.src):
            print project.src
Пример #4
0
def do(args):
    """Main entry point"""
    qiwt = qisrc.open_worktree(args.worktree)
    logger = qibuild.log.get_logger(__name__)
    for project in qiwt.buildable_projects:
        logger.info("Running `%s` for %s", " ".join(args.command), project.src)
        try:
            qibuild.command.call(args.command, cwd=project.path)
        except qibuild.command.CommandFailedException, err:
            if args.ignore_errors:
                logger.error(str(err))
                continue
            else:
                raise
Пример #5
0
def do(args):
    """ Main entry point """
    qiwt = qisrc.open_worktree(args.worktree)
    git_grep_opts = args.git_grep_opts
    git_grep_opts.append(args.pattern)
    logger = qibuild.log.get_logger(__name__)
    retcode = 0
    for project in qiwt.git_projects:
        qibuild.ui.info(qibuild.ui.green,
                        "Looking in", project.src, "...",
                        qibuild.ui.reset)
        git = qisrc.git.Git(project.path)
        (status, out) = git.call("grep", *git_grep_opts, raises=False)
        print out
        if status != 0:
            retcode = 1
    sys.exit(retcode)
Пример #6
0
def do(args):
    """Main entry point"""
    worktree = qisrc.open_worktree(args.worktree)
    projects = qisrc.cmdparse.projects_from_args(args)

    should_fetch_first = True
    if len(projects) == len(worktree.projects):
        sync_all(worktree, args)
        should_fetch_first = False

    git_projects = set()
    for project in projects:
        if project.git_project and not project.manifest:
            git_projects.add(project.git_project)

    ui.info(ui.green, "Synchronizing projects ...")
    git_projects = list(git_projects)
    git_projects.sort(key = operator.attrgetter("src"))
    errors = list()
    project_count = len(git_projects)
    for i, project in enumerate(git_projects):
        if project_count != 1:
            ui.info(
                ui.green, "*", ui.reset, "(%2i/%2i)" %  (i+1, project_count),
                ui.blue, project.src)
        else:
            ui.info(ui.bold, "Pulling", ui.blue, project.src)
        git = qisrc.git.open(project.path)
        error = git.update_branch(project.branch, project.remote,
                                 fetch_first=True)
        if error:
            errors.append((project.src, error))
    if not errors:
        return
    print
    ui.error("Fail to sync some projects")
    for (src, err) in errors:
        ui.info(ui.blue, src)
        print "-" * len(src)
        print indent(err, 2)
    sys.exit(1)
Пример #7
0
def do(args):
    """"Create a new project """
    # Try to open a worktree.
    # If not, ask the user if he wants to create one:
    qiwt = None
    qiwt = qisrc.open_worktree(args.worktree)

    project_name = args.project_name
    project_path = os.path.join(qiwt.root, project_name)

    if os.path.exists(project_path):
        raise Exception("%s already exists" % project_path)
    os.mkdir(project_path)
    copy_helper(project_name, project_path)

    if args.git:
        qibuild.command.call(["git", "init"], cwd=project_path)
        with open(os.path.join(project_path, ".gitignore"), "w") as fp:
            fp.write("build-*\n")
        qibuild.command.call(["git" , "add" , "."], cwd=project_path)
        qibuild.command.call(["git" , "commit" , "-m" , "initial commit"], cwd=project_path)

    LOGGER.info("New project initialized in %s", project_path)
    qiwt.add_project(project_path)
Пример #8
0
def do(args):
    """Main entry point"""
    qiwt = qisrc.open_worktree(args.worktree)
    errors = list()
    ui.info(ui.green, "Running `%s` on every project" % " ".join(args.command))
    c = 0
    count = len(qiwt.git_projects)
    for project in qiwt.git_projects:
        c += 1
        command = args.command[:]
        ui.info(ui.green, "*", ui.reset, "(%d/%d)" % (c, count), ui.blue, project.src)
        try:
            qibuild.command.call(command, cwd=project.path)
        except qibuild.command.CommandFailedException:
            if args.ignore_errors:
                errors.append(project)
                continue
            else:
                raise
    if not errors:
        return
    ui.error("Command failed on the following projects:")
    for project in errors:
        ui.info(ui.bold, " - ", project.src)
def do(args):
    """Main entry point"""
    src = args.src
    src = qibuild.sh.to_native_path(src)
    worktree = qisrc.open_worktree(args.worktree)
    worktree.remove_project(src, from_disk=args.from_disk)
Пример #10
0
def do(args):
    """Main entry point"""
    qiwt = qisrc.open_worktree(args.worktree)
    for project in qiwt.buildable_projects:
        LOGGER.info("%s", project.src)
        list_build_dir(project.path)
Пример #11
0
def do(args):
    """ Main method """
    qiwt = qisrc.open_worktree(args.worktree)
    gitrepo = list()
    dirty = list()
    incorrect = list()

    git_projects = qiwt.git_projects
    manifests = qiwt.get_manifest_projects()
    git_projects = list(set(git_projects) - set(manifests))

    sz = len(git_projects)
    i = 1
    oldsz = 0
    incorrect_projs = list()
    for git_project in git_projects:
        git = qisrc.git.open(git_project.path)
        if sys.stdout.isatty():
            src = git_project.src
            to_write = "checking (%d/%d)" % (i, sz)
            to_write += src
            to_write += _pad(oldsz, len(src))
            sys.stdout.write(to_write + "\r")
            sys.stdout.flush()
            oldsz = len(src)
            if i == sz:
                print "checking (%d/%d): done" % (i, sz), _pad(oldsz, 2)
        i = i + 1
        if git.is_valid():
            clean = git.is_clean(untracked=args.untracked_files)

            #clean worktree, but is the current branch sync with the remote one?
            if clean:
                branch = git.get_current_branch()
                if branch != git_project.branch:
                    incorrect_projs.append((git_project.src, branch, git_project.branch))
                    incorrect.append(git_project)
                tracking = git.get_tracking_branch()
                (ahead, behind) = stat_tracking_remote(git, branch, tracking)
                if ahead != 0 or behind != 0:
                    clean = False

            if args.show_branch or not clean:
                gitrepo.append(git_project)
            if not clean:
                dirty.append(git_project)

    LOGGER.info("Dirty projects: %d/%d", len(dirty), len(git_projects))

    max_len = _max_len(qiwt.root, gitrepo)
    for git_project in gitrepo:
        git = qisrc.git.open(git_project.path)
        shortpath = os.path.relpath(git_project.path, qiwt.root)
        if git.is_valid():
            branch = git.get_current_branch()
            tracking = git.get_tracking_branch()
            line = _add_pad(max_len, shortpath, " : %s tracking %s" %
                (branch, tracking))
            (ahead, behind) = stat_tracking_remote(git, branch, tracking)
            LOGGER.info(line)
            if ahead:
                print(" ## Your branch is %d commits ahead" % ahead)
            if behind:
                print(" ## Your branch is %d commits behind" % behind)

        if not git.is_clean(untracked=args.untracked_files):
            if args.untracked_files:
                (status_, out) = git.call("status", "-s", raises=False)
            else:
                (status_, out) = git.call("status", "-suno", raises=False)
            nlines = [ x[:3] + shortpath + "/" + x[3:] for x in out.splitlines() if len(x.strip()) > 0 ]
            print "\n".join(nlines)

    max_len = _max_len(qiwt.root, incorrect)
    max_len = max([max_len, len("Project")])
    if incorrect_projs:
        max_branch_len = max([len(x[1]) for x in incorrect_projs])
        max_branch_len = max([max_branch_len, len("Current")])
        print
        print " ## Warning: some projects are not on the expected branch"
        LOGGER.info("Project".ljust(max_len + 3) + "Current".ljust(max_branch_len + 3) + "Manifest")
        for (project, local_branch, manifest_branch) in incorrect_projs:
            LOGGER.info(project.ljust(max_len + 3) + local_branch.ljust(max_branch_len + 3) + manifest_branch)

    if not args.untracked_files:
        print
        print("Tips: use -u to show untracked files")