Repository: nosarthur/gita

Issue:
Revised symbols
May I kindly suggest adopting the following symbols:

symbol | meaning
--- | ---
`?` | Untracked changes
`+` | Added changes
`!` | Unstaged files
`»` | Renamed files
`✘` | Deleted files
`$` | Stashed changes
`=` | Unmerged changes
`⇡` | Unpushed changes (ahead of remote branch)
`⇣` | Unpulled changes (behind of remote branch)
`⇕` | Diverged changes (diverged with remote branch)

> _Based on https://spaceship-prompt.sh/sections/git/#Git-status-git_status_

I also believe it would be a great style to enclose them in `[` and `]` as well.

For example:

```
$ gita ll
blog     master   [!?] minor changes (2 weeks ago)
dotfiles master   [! ] update mac colmak ah json (31 minutes ago)
gita     master   [  ] update CN readme and image (35 minutes ago)
repol    feature1 [  ] add readme (50 minutes ago)
worklog  refactor [  ] Update onboard-desmond.m (7 months ago)
```

Comments:

Patch:
diff --git a/README.md b/README.md
index a1f7df3..79c6009 100644
--- a/README.md
+++ b/README.md
@@ -334,19 +334,16 @@ branch,commit_msg,commit_time
 ```
 
 Here `branch` includes both branch name and status.
-
-Another choice is to enable `spaceship_status`, which mimics
-the symbols used in [spaceship-prompt](https://spaceship-prompt.sh/sections/git/#Git-status-git_status).
+The status symbols are similar to the ones used in [spaceship-prompt](https://spaceship-prompt.sh/sections/git/#Git-status-git_status).
 
 To customize these symbols, add a file in `$XDG_CONFIG_HOME/gita/symbols.csv`.
-The default `spaceship_status` settings corresponds to
+The default settings corresponds to
 
 ```csv
 dirty,staged,untracked,local_ahead,remote_ahead,diverged,in_sync,no_remote
-!,+,?,↑,↓,⇕,,∅
+*,+,?,↑,↓,⇕,,∅
 ```
 Only the symbols to be overridden need to be defined.
-
 You can search unicode symbols [here](https://www.compart.com/en/unicode/).
 
 ### customize git command flags
diff --git a/gita/info.py b/gita/info.py
index f781cd0..10d8bea 100644
--- a/gita/info.py
+++ b/gita/info.py
@@ -89,7 +89,6 @@ def get_info_funcs(no_colors=False) -> List[Callable[[str], str]]:
     all_info_items = {
         "branch": partial(get_repo_status, no_colors=no_colors),
         "branch_name": get_repo_branch,
-        "spaceship_status": get_spaceship_status,
         "commit_msg": get_commit_msg,
         "commit_time": get_commit_time,
         "path": get_path,
@@ -196,64 +195,52 @@ def get_commit_time(prop: Dict[str, str]) -> str:
     return f"({result.stdout.strip()})"
 
 
-# better solution exists for python3.7+
-# https://stackoverflow.com/questions/11351032/named-tuple-and-default-values-for-optional-keyword-arguments
-Symbols = namedtuple(
-    "Symbols",
-    "dirty staged untracked local_ahead remote_ahead diverged in_sync no_remote",
-)
-Symbols.__new__.__defaults__ = ("",) * len(Symbols._fields)
-default_symbols = Symbols("*", "+", "?")
+default_symbols = {
+    "dirty": "*",
+    "staged": "+",
+    "untracked": "?",
+    "local_ahead": "↑",
+    "remote_ahead": "↓",
+    "diverged": "⇕",
+    "in_sync": "",
+    "no_remote": "∅",
+    "": "",
+}
 
 
 @lru_cache()
-def get_symbols(baseline: Symbols = default_symbols) -> Dict[str, str]:
+def get_symbols() -> Dict[str, str]:
     """
     return status symbols with customization
     """
-    symbols = baseline._asdict()
-    symbols[""] = ""
     custom = {}
     csv_config = Path(common.get_config_fname("symbols.csv"))
     if csv_config.is_file():
         with open(csv_config, "r") as f:
             reader = csv.DictReader(f)
             custom = next(reader)
-    symbols.update(custom)
-    return symbols
+    default_symbols.update(custom)
+    return default_symbols
 
 
 def get_repo_status(prop: Dict[str, str], no_colors=False) -> str:
-    head = get_head(prop["path"])
-    colors = {situ: Color[name].value for situ, name in get_color_encoding().items()}
-    dirty, staged, untracked, situ = _get_repo_status(prop, skip_situ=no_colors)
-    symbols = get_symbols(default_symbols)
-    info = f"{head:<10} [{symbols[dirty]+symbols[staged]+symbols[untracked]}]"
+    branch = get_head(prop["path"])
+    dirty, staged, untracked, situ = _get_repo_status(prop)
+    symbols = get_symbols()
+    info = f"{branch:<10} [{symbols[dirty]+symbols[staged]+symbols[untracked]+symbols[situ]}]"
 
     if no_colors:
-        return f"{info:<17}"
+        return f"{info:<18}"
+    colors = {situ: Color[name].value for situ, name in get_color_encoding().items()}
     color = colors[situ]
-    return f"{color}{info:<17}{Color.end}"
-
-
-spaceship = Symbols("!", "+", "?", "↑", "↓", "⇕", "", "∅")
-
-
-def get_spaceship_status(prop: Dict[str, str]) -> str:
-    head = get_head(prop["path"])
-    dirty, staged, untracked, situ = _get_repo_status(prop)
-    symbols = get_symbols(spaceship)
-    info = f"{head:<10} [{symbols[dirty]+symbols[staged]+symbols[untracked]+symbols[situ]}]"
-    return f"{info:<18}"
+    return f"{color}{info:<18}{Color.end}"
 
 
 def get_repo_branch(prop: Dict[str, str]) -> str:
     return get_head(prop["path"])
 
 
-def _get_repo_status(
-    prop: Dict[str, str], skip_situ=False
-) -> Tuple[str, str, str, str]:
+def _get_repo_status(prop: Dict[str, str]) -> Tuple[str, str, str, str]:
     """
     Return the status of one repo
     """
@@ -263,9 +250,6 @@ def _get_repo_status(
     staged = "staged" if run_quiet_diff(flags, ["--cached"], path) else ""
     untracked = "untracked" if has_untracked(flags, path) else ""
 
-    if skip_situ:
-        return dirty, staged, untracked, ""
-
     diff_returncode = run_quiet_diff(flags, ["@{u}", "@{0}"], path)
     if diff_returncode == 128:
         situ = "no_remote"
@@ -285,7 +269,6 @@ def _get_repo_status(
 ALL_INFO_ITEMS = {
     "branch",
     "branch_name",
-    "spaceship_status",
     "commit_msg",
     "commit_time",
     "path",
diff --git a/setup.py b/setup.py
index d62cb5f..4950b49 100644
--- a/setup.py
+++ b/setup.py
@@ -7,7 +7,7 @@ with open("README.md", encoding="utf-8") as f:
 setup(
     name="gita",
     packages=["gita"],
-    version="0.16.5",
+    version="0.16.6",
     license="MIT",
     description="Manage multiple git repos with sanity",
     long_description=long_description,


Test patch:
diff --git a/tests/test_main.py b/tests/test_main.py
index 7c82501..a877160 100644
--- a/tests/test_main.py
+++ b/tests/test_main.py
@@ -130,12 +130,12 @@ class TestLsLl:
         [
             (
                 PATH_FNAME,
-                "repo1 \x1b[31mmaster     [*+?] \x1b[0m msg \nrepo2 \x1b[31mmaster     [*+?] \x1b[0m msg \nxxx   \x1b[31mmaster     [*+?] \x1b[0m msg \n",
+                "repo1 \x1b[31mmaster     [*+?⇕] \x1b[0m msg \nrepo2 \x1b[31mmaster     [*+?⇕] \x1b[0m msg \nxxx   \x1b[31mmaster     [*+?⇕] \x1b[0m msg \n",
             ),
             (PATH_FNAME_EMPTY, ""),
             (
                 PATH_FNAME_CLASH,
-                "repo1 \x1b[31mmaster     [*+?] \x1b[0m msg \nrepo2 \x1b[31mmaster     [*+?] \x1b[0m msg \n",
+                "repo1 \x1b[31mmaster     [*+?⇕] \x1b[0m msg \nrepo2 \x1b[31mmaster     [*+?⇕] \x1b[0m msg \n",
             ),
         ],
     )
@@ -535,8 +535,7 @@ class TestInfo:
         __main__.f_info(args)
         out, err = capfd.readouterr()
         assert (
-            "In use: branch,commit_msg,commit_time\nUnused: branch_name,path,spaceship_status\n"
-            == out
+            "In use: branch,commit_msg,commit_time\nUnused: branch_name,path\n" == out
         )
         assert err == ""
 
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 1e4f125..2936f0e 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -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",
         ),
     ],
 )