def show_overview_command(): incidents = list(incident.load_all_incidents()) if not log.SHORT_MODE: log.echo("Recently opened incidents:") log_incidents(list(filter(lambda inc: not inc.closed, incidents))[:5]) log.echo("Recent incidents:") log_incidents(incidents[:5])
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)
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)
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!")
def vcs_log_command(ctx): current = ctx.obj["INCIDENT"] repo = get_repository(current) log.echo(repo.git.log())
def log_incidents(incidents): for inc in incidents: fmt, params = format_incident(inc) log.echo(fmt, order=["incident"], **params)
def log_incident(inc): fmt, params = format_long_incident(inc) log.echo(fmt, order=["incident"], **params)