Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add brackets around status symbols and change untracked symbol to ? #247

Merged
merged 4 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ symbol | meaning
---|---
`+`| staged changes
`*`| unstaged changes
`_`| untracked files/folders
`?`| untracked files/folders

The bookkeeping sub-commands are

Expand Down
2 changes: 1 addition & 1 deletion doc/README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

- `+`: 暂存(staged)
- `*`: 未暂存(unstaged)
- `_`: 未追踪(untracked)
- `?`: 未追踪(untracked)

基础指令:

Expand Down
6 changes: 3 additions & 3 deletions gita/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ def get_repo_status(prop: Dict[str, str], no_colors=False) -> str:
head = get_head(prop["path"])
dirty, staged, untracked, color = _get_repo_status(prop, no_colors)
if color:
return f'{color}{head+" "+dirty+staged+untracked:<10}{Color.end}'
return f'{head+" "+dirty+staged+untracked:<10}'
return f"{color}{head+' ['+dirty+staged+untracked+']':<13}{Color.end}"
return f"{head+' ['+dirty+staged+untracked+']':<13}"


def get_repo_branch(prop: Dict[str, str]) -> str:
Expand All @@ -215,7 +215,7 @@ def _get_repo_status(prop: Dict[str, str], no_colors: bool) -> Tuple[str]:
flags = prop["flags"]
dirty = "*" if run_quiet_diff(flags, [], path) else ""
staged = "+" if run_quiet_diff(flags, ["--cached"], path) else ""
untracked = "_" if has_untracked(flags, path) else ""
untracked = "?" if has_untracked(flags, path) else ""

if no_colors:
return dirty, staged, untracked, ""
Expand Down
4 changes: 2 additions & 2 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@ def test_ls(self, monkeypatch, capfd):
[
(
PATH_FNAME,
"repo1 cmaster dsu\x1b[0m msg \nrepo2 cmaster dsu\x1b[0m msg \nxxx cmaster dsu\x1b[0m msg \n",
"repo1 cmaster [dsu] \x1b[0m msg \nrepo2 cmaster [dsu] \x1b[0m msg \nxxx cmaster [dsu] \x1b[0m msg \n",
),
(PATH_FNAME_EMPTY, ""),
(
PATH_FNAME_CLASH,
"repo1 cmaster dsu\x1b[0m msg \nrepo2 cmaster dsu\x1b[0m msg \n",
"repo1 cmaster [dsu] \x1b[0m msg \nrepo2 cmaster [dsu] \x1b[0m msg \n",
),
],
)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,17 @@ def test_auto_group(repos, paths, expected):
(
[{"abc": {"path": "/root/repo/", "type": "", "flags": []}}, False],
True,
"abc \x1b[31mrepo *+_ \x1b[0m msg xx",
"abc \x1b[31mrepo [*+?] \x1b[0m msg xx",
),
(
[{"abc": {"path": "/root/repo/", "type": "", "flags": []}}, True],
True,
"abc repo *+_ msg xx",
"abc repo [*+?] msg xx",
),
(
[{"repo": {"path": "/root/repo2/", "type": "", "flags": []}}, False],
False,
"repo \x1b[32mrepo _ \x1b[0m msg xx",
"repo \x1b[32mrepo [?] \x1b[0m msg xx",
),
],
)
Expand Down