Skip to content

Commit

Permalink
add brackets around status symbols and change untracked symbol to ? (#…
Browse files Browse the repository at this point in the history
…247)

* add brackets around status symbols and change untracked symbol to ?

* fix unit tests

* make alignment longer

* update the chinese readme
  • Loading branch information
nosarthur authored Jul 12, 2023
1 parent 6a0ce4b commit fe06bd2
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
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

0 comments on commit fe06bd2

Please sign in to comment.