pygments-shell-console 0.2.1__tar.gz → 0.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. {pygments_shell_console-0.2.1 → pygments_shell_console-0.4}/PKG-INFO +1 -1
  2. {pygments_shell_console-0.2.1 → pygments_shell_console-0.4}/git_lexer.py +11 -0
  3. {pygments_shell_console-0.2.1 → pygments_shell_console-0.4}/pyproject.toml +1 -1
  4. {pygments_shell_console-0.2.1 → pygments_shell_console-0.4}/shellconsole_lexer.py +1 -1
  5. {pygments_shell_console-0.2.1 → pygments_shell_console-0.4}/test/test_git_status.py +48 -0
  6. {pygments_shell_console-0.2.1 → pygments_shell_console-0.4}/test/test_prompts.py +14 -0
  7. {pygments_shell_console-0.2.1 → pygments_shell_console-0.4}/.github/workflows/publish-to-pypi.yml +0 -0
  8. {pygments_shell_console-0.2.1 → pygments_shell_console-0.4}/.gitignore +0 -0
  9. {pygments_shell_console-0.2.1 → pygments_shell_console-0.4}/README.md +0 -0
  10. {pygments_shell_console-0.2.1 → pygments_shell_console-0.4}/examples/git_lg.example +0 -0
  11. {pygments_shell_console-0.2.1 → pygments_shell_console-0.4}/examples/git_log.example +0 -0
  12. {pygments_shell_console-0.2.1 → pygments_shell_console-0.4}/examples/git_show.example +0 -0
  13. {pygments_shell_console-0.2.1 → pygments_shell_console-0.4}/examples/status.example +0 -0
  14. {pygments_shell_console-0.2.1 → pygments_shell_console-0.4}/examples/test.exmpl +0 -0
  15. {pygments_shell_console-0.2.1 → pygments_shell_console-0.4}/examples/test.sh +0 -0
  16. {pygments_shell_console-0.2.1 → pygments_shell_console-0.4}/shellconsole_style.py +0 -0
  17. {pygments_shell_console-0.2.1 → pygments_shell_console-0.4}/test/__init__.py +0 -0
  18. {pygments_shell_console-0.2.1 → pygments_shell_console-0.4}/test/test_git.py +0 -0
  19. {pygments_shell_console-0.2.1 → pygments_shell_console-0.4}/test/test_git_branch.py +0 -0
  20. {pygments_shell_console-0.2.1 → pygments_shell_console-0.4}/test/test_git_log.py +0 -0
  21. {pygments_shell_console-0.2.1 → pygments_shell_console-0.4}/test/test_git_pretty_log.py +0 -0
  22. {pygments_shell_console-0.2.1 → pygments_shell_console-0.4}/test/test_git_show.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pygments-shell-console
3
- Version: 0.2.1
3
+ Version: 0.4
4
4
  Requires-Dist: pygments
5
5
  Description-Content-Type: text/markdown
6
6
 
@@ -29,6 +29,7 @@ STANDARD_TYPES.update({
29
29
  Token.Git.Refs: 'git-r',
30
30
  Token.Git.Untracked: 'git-untr',
31
31
  Token.Git.Modified: 'git-mod',
32
+ Token.Git.Unmerged: 'git-unm',
32
33
  Token.Git.Staged: 'git-stg',
33
34
  Token.Git.Show: 'git-show',
34
35
  Token.Git.Show.Header: 'git-show-h',
@@ -129,6 +130,7 @@ class GitStatusLexer(RegexLexer):
129
130
  (r'\s*Untracked files:\n', Generic.Output, 'untracked'),
130
131
  (r'\s*Changes not staged for commit:\n', Generic.Output, 'modified'),
131
132
  (r'\s*Changes to be committed:\n', Generic.Output, 'staged'),
133
+ (r'\s*Unmerged paths:\n', Generic.Output, 'unmerged'),
132
134
  (r'^.*\n', using(GitLexer)),
133
135
  ],
134
136
  'untracked': [
@@ -158,6 +160,15 @@ class GitStatusLexer(RegexLexer):
158
160
  Whitespace
159
161
  )),
160
162
  ],
163
+ 'unmerged': [
164
+ (r'^\s*\n', Whitespace, '#pop'),
165
+ (r'^\s+\(.*\)\n', Generic.Output),
166
+ (r'^(\s*)([^\n]+)(\n)', bygroups(
167
+ Whitespace,
168
+ Token.Git.Unmerged,
169
+ Whitespace
170
+ )),
171
+ ],
161
172
  }
162
173
 
163
174
  class GitLogLexer(RegexLexer):
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "pygments-shell-console" # change this to a package name for your plugin
7
- version = "0.2.1"
7
+ version = "0.4"
8
8
  dependencies = ["pygments"]
9
9
  readme = "README.md"
10
10
 
@@ -37,7 +37,7 @@ class ShellConsoleLexer(Lexer):
37
37
  r'(?P<venv>\([^\)]*\))?', # Virtualenv
38
38
  r'(\s*)?', # Whitespace
39
39
  r'\[?', # Start bracketed prompt
40
- r'(?P<user_host>[^\s@]+@[^\s]+?)', # user@host
40
+ r'(?P<user_host>[\S @]+@[^\s]+?)', # user@host
41
41
  r'(\s*)', # Whitespace
42
42
  r'(?:(\:)|(\s+))', # Separator: colon or space
43
43
  r'(\s*)', # Whitespace
@@ -202,3 +202,51 @@ def test_git_status_whit_hint():
202
202
  (Token.Git.Hint, "hint: You've added another git status command\n"),
203
203
  (Token.Generic.Output, "On branch main\n"),
204
204
  ]
205
+
206
+ def test_git_status_unmerged():
207
+ lexer = ShellConsoleLexer()
208
+ text = (
209
+ "user@host:~/directory (main) $ git status\n"
210
+ "On branch main\n"
211
+ "You have unmerged paths.\n"
212
+ " (fix conflicts and run \"git commit\")\n"
213
+ " (use \"git merge --abort\" to abort the merge)\n"
214
+ "\n"
215
+ "Unmerged paths:\n"
216
+ " (use \"git restore --staged <file>...\" to unstage)\n"
217
+ " (use \"git add <file>...\" to mark resolution)\n"
218
+ " both modified: README.md\n"
219
+ "\n"
220
+ "no changes added to commit (use \"git add\" and/or \"git commit -a\")\n"
221
+ )
222
+
223
+ tokens = list(lexer.get_tokens(text))
224
+
225
+ assert tokens == [
226
+ (Token.Generic.Prompt.UserHost, "user@host"),
227
+ (Token.Generic.Prompt, ":"),
228
+ (Token.Generic.Prompt.Directory, "~/directory"),
229
+ (Token.Text.Whitespace, " "),
230
+ (Token.Generic.Prompt.GitBranch, "(main)"),
231
+ (Token.Text.Whitespace, " "),
232
+ (Token.Generic.Prompt, "$"),
233
+ (Token.Text.Whitespace, " "),
234
+ (Token.Text, "git"),
235
+ (Token.Text.Whitespace, " "),
236
+ (Token.Text, "status"),
237
+ (Token.Text.Whitespace, "\n"),
238
+ # Output
239
+ (Token.Generic.Output, "On branch main\n"),
240
+ (Token.Generic.Output, "You have unmerged paths.\n"),
241
+ (Token.Generic.Output, " (fix conflicts and run \"git commit\")\n"),
242
+ (Token.Generic.Output, " (use \"git merge --abort\" to abort the merge)\n"),
243
+ (Token.Text.Whitespace, "\n"),
244
+ (Token.Generic.Output, "Unmerged paths:\n"),
245
+ (Token.Generic.Output, " (use \"git restore --staged <file>...\" to unstage)\n"),
246
+ (Token.Generic.Output, " (use \"git add <file>...\" to mark resolution)\n"),
247
+ (Token.Text.Whitespace, " "),
248
+ (Token.Git.Unmerged, "both modified: README.md"),
249
+ (Token.Text.Whitespace, "\n"),
250
+ (Token.Text.Whitespace, "\n"),
251
+ (Token.Generic.Output, "no changes added to commit (use \"git add\" and/or \"git commit -a\")\n"),
252
+ ]
@@ -212,3 +212,17 @@ def test_bash_prompt_with_virtualenv_and_git_branch_and_command_output():
212
212
  (Token.Text.Whitespace, "\n"),
213
213
  (Token.Generic.Output, "Hello world!\n"),
214
214
  ]
215
+
216
+ def test_bash_prompt_with_spaces():
217
+ lexer = ShellConsoleLexer()
218
+ prompt = "Fri Sep 13 09:30:00 user@host:~/project $"
219
+
220
+ tokens = list(lexer.get_tokens(prompt))
221
+
222
+ assert tokens == [
223
+ (Token.Generic.Prompt.UserHost, "Fri Sep 13 09:30:00 user@host"),
224
+ (Token.Generic.Prompt, ":"),
225
+ (Token.Generic.Prompt.Directory, "~/project"),
226
+ (Token.Text.Whitespace, " "),
227
+ (Token.Generic.Prompt, "$\n"),
228
+ ]