コード例 #1
0
 def show_object_handler():
     current = incident.choose_incident(name,
                                        allow_current=True,
                                        multiple=True)
     if current is None:
         incidents = incident.find_incidents_by_tag(name)
         if not incidents:
             log.error("Incident or tag doesn't exist")
             ctx.abort()
         incidents = [incident.choose_incident(inc) for inc in incidents]
         log.echo("Incidents tagged as #{tag}", tag=name)
         log_incidents(incidents)
     elif len(current) == 1:
         log_incident(current[0])
     else:
         log_incidents(current)
コード例 #2
0
def shell_export_command(ctx, incident_id):
    current = incident.choose_incident(incident_id)
    if current is None:
        ctx.abort()
    log.shell("tar -zcvf {archive} -C {path} {identifier}",
              archive="dirt-{}.tar.gz".format(current.identifier),
              path=path.get_incidents_path(),
              identifier=current.identifier)
コード例 #3
0
def switch_command(ctx, incident_id):
    current = incident.choose_incident(incident_id, allow_current=False)
    if current is None:
        log.error("No incident found.")
        ctx.abort()
    incident.set_current_incident(current)
    log.success("Switched to {incident}", incident=current.identifier)
    ctx.obj["INCIDENT"] = current
コード例 #4
0
def del_command(ctx, incident_id, force):
    current = incident.choose_incident(incident_id)
    if current is None:
        log.error("No incident found.")
        ctx.abort()
    if current.closed and not force:
        log.error("Incident is closed - you must open it before adding items.")
        ctx.abort()
    ctx.obj["INCIDENT"] = current
コード例 #5
0
ファイル: __init__.py プロジェクト: psrok1/dirt-vcs
def vcs_command(ctx, incident_id):
    """
    Here we're adding new command to dirt - vcs
    """
    current = incident.choose_incident(incident_id)
    if current is None:
        log.error("No incident found.")
        ctx.abort()
    ctx.obj["INCIDENT"] = current
コード例 #6
0
def open_command(ctx, incident_id):
    current = incident.choose_incident(incident_id)
    if current is None:
        log.error("No incident found.")
        ctx.abort()
    if not current.closed:
        log.error("Incident is opened yet")
        ctx.abort()
    current.closed = False
    current.store()
    log.success("Incident {incident} opened", incident=current.identifier)
    ctx.obj["INCIDENT"] = current
コード例 #7
0
def incident_expand_arg_list(partial):
    if ":" in partial:
        name, relpath = partial.split(":", 1)
        try:
            current = incident.choose_incident(name)
            return path_list(relpath, relpath=current.dirpath)
        except RuntimeError:
            return []
    else:
        return [
            inc + ":"
            for inc in incident_list(partial) if inc.startswith(partial)
        ] + path_list(partial)
コード例 #8
0
ファイル: command_close.py プロジェクト: psrok1/dirt-vcs
def pre_hook_close_command(ctx, incident_id, *args, **kwargs):
    """
    Pre-hook on "dirt close" command.
    We need to be sure that all changes are committed before closing repository
    """
    incident = choose_incident(incident_id)
    if incident is None:
        return  # Let dirt handle it
    if not repository.uncommitted_files(incident):
        return
    warning(
        "Uncommitted changes left in incident you want to close. They will be committed automatically"
    )
    if not click.confirm("Are you sure?"):
        ctx.abort()
コード例 #9
0
def meta_del_rel_command(ctx, related):
    current = ctx.obj["INCIDENT"]
    with_inc = incident.choose_incident(related, allow_current=False)
    if with_inc is None:
        log.error("No incident found.")
        ctx.abort()

    current.remove_relation(with_inc)
    with_inc.remove_relation(current)

    current.store()
    with_inc.store()

    log.success("Unmarked {incident} as related with {related}",
                incident=current.identifier,
                related=with_inc.identifier)
コード例 #10
0
def meta_add_rel_command(ctx, related):
    current = ctx.obj["INCIDENT"]
    with_inc = incident.choose_incident(related, allow_current=False)
    if with_inc is None:
        log.error("No incident found.")
        ctx.abort()
    if with_inc.uuid == current.uuid:
        log.error("Incidents are the same object - relation can't be added")
        ctx.abort()

    current.add_relation(with_inc)
    with_inc.add_relation(current)

    current.store()
    with_inc.store()

    log.success("Marked {incident} as related with {related}",
                incident=current.identifier,
                related=with_inc.identifier)
コード例 #11
0
def shell_cd_command(ctx, incident_id):
    current = incident.choose_incident(incident_id)
    if current is None:
        ctx.abort()
    log.shell("cd {path}", path=current.dirpath)