Пример #1
0
def forget(identifier):
    '''
    Tells homely to forget about a dotfiles repository that was previously
    added. You can then run `homely update` to have homely perform automatic
    cleanup of anything that was installed by that dotfiles repo.

    REPO
        This should be the path to a local dotfiles repository that has already
        been registered using `homely add`. You may specify multiple REPOs to
        remove at once.
    '''
    errors = False
    for one in identifier:
        cfg = RepoListConfig()
        info = cfg.find_by_any(one, "ilc")
        if not info:
            warn("No repos matching %r" % one)
            errors = True
            continue

        # update the config ...
        note("Removing record of repo [%s] at %s" %
             (info.shortid(), info.localrepo.repo_path))
        with saveconfig(RepoListConfig()) as cfg:
            cfg.remove_repo(info.repoid)

    # if there were errors, then don't try and do an update
    if errors:
        sys.exit(1)
Пример #2
0
def update(identifiers, nopull, only):
    '''
    Performs a `git pull` in each of the repositories registered with
    `homely add`, runs all of their HOMELY.py scripts, and then performs
    automatic cleanup as necessary.

    REPO
        This should be the path to a local dotfiles repository that has already
        been registered using `homely add`. If you specify one or more `REPO`s
        then only the HOMELY.py scripts from those repositories will be run,
        and automatic cleanup will not be performed (automatic cleanup is only
        possible when homely has done an update of all repositories in one go).
        If you do not specify a REPO, all repositories' HOMELY.py scripts will
        be run.

    The --nopull and --only options are useful when you are working on your
    HOMELY.py script - the --nopull option stops you from wasting time checking
    the internet for the same updates on every run, and the --only option
    allows you to execute only the section you are working on.
    '''
    mkcfgdir()
    setallowpull(not nopull)

    cfg = RepoListConfig()
    if len(identifiers):
        updatedict = {}
        for identifier in identifiers:
            repo = cfg.find_by_any(identifier, "ilc")
            if repo is None:
                hint = "Try running %s add /path/to/this/repo first" % CMD
                raise Fatal("Unrecognised repo %s (%s)" % (identifier, hint))
            updatedict[repo.repoid] = repo
        updatelist = updatedict.values()
        cleanup = len(updatelist) == cfg.repo_count()
    else:
        updatelist = list(cfg.find_all())
        cleanup = True
    success = run_update(updatelist,
                         pullfirst=not nopull,
                         only=only,
                         cancleanup=cleanup)
    if not success:
        sys.exit(1)