コード例 #1
0
def meta_add_tag_command(ctx, tag):
    current = ctx.obj["INCIDENT"]
    tag = current.add_tag(tag)
    if tag is None:
        log.error("Invalid tag name! Must start with letter and contain only letters, digits, underscores or dashes")
        ctx.abort()
    current.store()
    log.success("Tagged as {tag}", tag="#" + tag)
コード例 #2
0
 def custom_shell_command(args):
     try:
         args = [quote(incident.expand_incident_arg(arg)) for arg in args]
     except RuntimeError as e:
         log.error(str(e))
         ctx.abort()
         return
     log.shell(name+' '+(' '.join(args)))
コード例 #3
0
def show_tags_command(ctx):
    tags = os.listdir(path.get_tags_path())
    if not tags:
        log.error("No tags.")
        ctx.abort()
    log.echo("Known tags")
    for tag in tags:
        log.echo("* {tag}", tag=tag)
コード例 #4
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
コード例 #5
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
コード例 #6
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
コード例 #7
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
コード例 #8
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)
コード例 #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 vcs_commit_command(ctx, message):
    current = ctx.obj["INCIDENT"]
    changes = repository.uncommitted_files(current)
    default_message = "(empty)"

    if not changes:
        log.error("No pending changes!")
        ctx.abort()

    if not message:
        if not log.QUIET_MODE:
            log.warning(
                "Empty commit message. Please provide commit description.")
            message = click.prompt("Description:", default=default_message)
        else:
            message = default_message

    repository.commit(current, message)

    log.echo("Changed files:", ignore_short=True)
    for path in changes:
        log.echo("* {path}", path=path, ignore_short=True)

    log.success("Changes committed successfully!")