Skip to content

Commit

Permalink
feat(cli): unified the display format of description in CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
yeyong.yu committed Jul 14, 2021
1 parent 58fcf1d commit 97dc22a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
20 changes: 16 additions & 4 deletions tensorbay/cli/draft.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
# And an empty draft message aborts the creation.
"""

_FULL_DRAFT_MESSAGE = """Branch:{}({})
{}
{}"""


def _implement_draft( # pylint: disable=too-many-arguments
obj: Dict[str, str], tbrn: str, is_list: bool, edit: bool, close: bool, message: Tuple[str, ...]
Expand Down Expand Up @@ -86,15 +91,22 @@ def _echo_draft(
error(f'The branch "{branch_name}" does not exist')

if branch.commit_id != ROOT_COMMIT_ID:
click.echo(f"Branch: {branch_name}({branch.commit_id})")
commit_id = branch.commit_id
else:
click.echo(f"Branch: {branch_name}")
commit_id = ""

if not title:
title = "<no title>"
click.echo(f"\n {title}\n")
if description:
click.echo(f" {description}\n")
description = "\n".join(("", " " + description.replace("\n", "\n "), ""))
click.echo(
_FULL_DRAFT_MESSAGE.format(
branch_name,
commit_id,
title,
description,
)
)


def _edit_draft(dataset_client: DatasetClientType, info: TBRN, message: Tuple[str, ...]) -> None:
Expand Down
9 changes: 5 additions & 4 deletions tensorbay/cli/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
Date: {}
{}
{}
{}
"""


Expand All @@ -45,10 +43,13 @@ def _get_oneline_log(commit: Commit) -> str:


def _get_full_log(commit: Commit) -> str:
description = commit.description
if description:
description = "\n".join(("", " " + description.replace("\n", "\n "), ""))
return _FULL_LOG.format(
commit.commit_id,
commit.committer.name,
datetime.fromtimestamp(commit.committer.date).strftime("%a %b %d %H:%M:%S %y"),
commit.title,
commit.description,
description,
)

0 comments on commit 97dc22a

Please sign in to comment.