diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-07 05:49:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-07 05:49:49 +0000 |
commit | 0527b747cbc5f600e9f115dbf4e1af43ee211b6d (patch) | |
tree | 107b8039026ed8d0775f34cccab8a8fcac44b5a0 | |
parent | Adding upstream version 1.3.1. (diff) | |
download | powerline-gitstatus-upstream.tar.xz powerline-gitstatus-upstream.zip |
Adding upstream version 1.3.2.upstream/1.3.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
-rw-r--r-- | README.md | 33 | ||||
-rw-r--r-- | powerline_gitstatus/segments.py | 20 |
2 files changed, 36 insertions, 17 deletions
@@ -37,6 +37,8 @@ Installation ### On Debian/Ubuntu +On a recent enough Debian (at least Stretch with backports enabled) or Ubuntu (at least 18.10) there is an official package available. + ```txt apt install powerline-gitstatus ``` @@ -104,10 +106,12 @@ Do this by passing `false` to the `use_dash_c` argument, for example in `.config Optionally, a tag description for the current branch may be displayed using the `show_tag` option. Valid values for this argument are: + * `last` : shows the most recent tag * `annotated` : shows the most recent annotated tag * `contains` : shows the closest tag that comes after the current commit * `exact` : shows a tag only if it matches the current commit + You can enable this by passing one of these to the `show_tag` argument, for example in `.config/powerline/themes/shell/__main__.json`: ```json @@ -123,7 +127,7 @@ Note: before v1.3.0, the behavior when the value is `True` was `last`. As of v1. Optionally the format in which Gitstatus shows information can be customized. This allows to use a different symbol or remove a fragment if desired. You can -customize string formats for _tag_, _behind_, _ahead_, _staged_, _unmerged_, +customize string formats for _branch_, _tag_, _behind_, _ahead_, _staged_, _unmerged_, _changed_, _untracked_ and _stash_ fragments with the following arguments in a theme configuration file, for example `.config/powerline/themes/shell/__main__.json`: @@ -131,14 +135,15 @@ theme configuration file, for example `.config/powerline/themes/shell/__main__.j "gitstatus": { "args": { "formats": { - "tag": " {}", - "behind": " {}", - "ahead": " {}", - "staged": " {}", - "unmerged": " {}", - "changed": " {}", - "untracked": " {}", - "stashed": " {}" + "branch": "\ue0a0 {}", + "tag": " ★ {}", + "behind": " ↓ {}", + "ahead": " ↑ {}", + "staged": " ● {}", + "unmerged": " ✖ {}", + "changed": " ✚ {}", + "untracked": " … {}", + "stashed": " ⚑ {}" } } } @@ -155,6 +160,16 @@ place of the branch name. This can be replaced with a description of the closest } } ``` + +By default, if your local branch has untracked files but no other changes, the branch status will be highlighted as dirty in the segment. You can disable this behavior by setting the `untracked_not_dirty` argument to `true`, for example in `.config/powerline/themes/shell/__main__.json`: + +```json +"gitstatus": { + "args": { + "untracked_not_dirty": true + } +} +``` License ------- diff --git a/powerline_gitstatus/segments.py b/powerline_gitstatus/segments.py index 81c51db..cdd0a01 100644 --- a/powerline_gitstatus/segments.py +++ b/powerline_gitstatus/segments.py @@ -11,9 +11,9 @@ class GitStatusSegment(Segment): def execute(self, pl, command): pl.debug('Executing command: %s' % ' '.join(command)) - + git_env = os.environ.copy() - git_env['LC_ALL'] = 'C' + git_env['LC_ALL'] = 'C' proc = Popen(command, stdout=PIPE, stderr=PIPE, env=git_env) out, err = [item.decode('utf-8') for item in proc.communicate()] @@ -27,13 +27,13 @@ class GitStatusSegment(Segment): def get_base_command(self, cwd, use_dash_c): if use_dash_c: - return ['git', '-C', cwd] + return ['git', '-c', 'core.fsmonitor=', '-C', cwd] while cwd and cwd != os.sep: gitdir = os.path.join(cwd, '.git') if os.path.isdir(gitdir): - return ['git', '--git-dir=%s' % gitdir, '--work-tree=%s' % cwd] + return ['git', '-c', 'core.fsmonitor=', '--git-dir=%s' % gitdir, '--work-tree=%s' % cwd] cwd = os.path.dirname(cwd) @@ -80,10 +80,10 @@ class GitStatusSegment(Segment): return (staged, unmerged, changed, untracked) - def build_segments(self, formats, branch, detached, tag, behind, ahead, staged, unmerged, changed, untracked, stashed): + def build_segments(self, formats, branch, detached, tag, behind, ahead, staged, unmerged, changed, untracked, stashed, untracked_not_dirty): if detached: branch_group = 'gitstatus_branch_detached' - elif staged or unmerged or changed or untracked: + elif staged or unmerged or changed or (untracked and not untracked_not_dirty): branch_group = 'gitstatus_branch_dirty' else: branch_group = 'gitstatus_branch_clean' @@ -111,7 +111,7 @@ class GitStatusSegment(Segment): return segments - def __call__(self, pl, segment_info, use_dash_c=True, show_tag=False, formats={}, detached_head_style='revision'): + def __call__(self, pl, segment_info, use_dash_c=True, show_tag=False, formats={}, detached_head_style='revision', untracked_not_dirty=False): pl.debug('Running gitstatus %s -C' % ('with' if use_dash_c else 'without')) cwd = segment_info['getcwd']() @@ -160,7 +160,7 @@ class GitStatusSegment(Segment): else: tag = tag[0] - return self.build_segments(formats, branch, detached, tag, behind, ahead, staged, unmerged, changed, untracked, stashed) + return self.build_segments(formats, branch, detached, tag, behind, ahead, staged, unmerged, changed, untracked, stashed, untracked_not_dirty) gitstatus = with_docstring(GitStatusSegment(), @@ -189,6 +189,10 @@ if that number is greater than zero. Display style when in detached HEAD state. Valid values are ``revision``, which shows the current revision id, and ``ref``, which shows the closest reachable ref object. The default is ``revision``. +:param untracked_not_dirty: + Untracked files alone will not mark the git branch status as dirty. + False by default. + Divider highlight group used: ``gitstatus:divider``. Highlight groups used: ``gitstatus_branch_detached``, ``gitstatus_branch_dirty``, ``gitstatus_branch_clean``, ``gitstatus_branch``, ``gitstatus_tag``, ``gitstatus_behind``, ``gitstatus_ahead``, ``gitstatus_staged``, ``gitstatus_unmerged``, ``gitstatus_changed``, ``gitstatus_untracked``, ``gitstatus_stashed``, ``gitstatus``. |