pygments-shell-console 0.8.2__tar.gz → 0.8.3__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 (23) hide show
  1. {pygments_shell_console-0.8.2 → pygments_shell_console-0.8.3}/.github/workflows/publish-to-pypi.yml +3 -3
  2. {pygments_shell_console-0.8.2 → pygments_shell_console-0.8.3}/PKG-INFO +2 -2
  3. {pygments_shell_console-0.8.2 → pygments_shell_console-0.8.3}/git_lexer.py +10 -7
  4. {pygments_shell_console-0.8.2 → pygments_shell_console-0.8.3}/pyproject.toml +1 -1
  5. {pygments_shell_console-0.8.2 → pygments_shell_console-0.8.3}/test/test_git_pretty_log.py +61 -0
  6. {pygments_shell_console-0.8.2 → pygments_shell_console-0.8.3}/.gitignore +0 -0
  7. {pygments_shell_console-0.8.2 → pygments_shell_console-0.8.3}/README.md +0 -0
  8. {pygments_shell_console-0.8.2 → pygments_shell_console-0.8.3}/examples/git_lg.example +0 -0
  9. {pygments_shell_console-0.8.2 → pygments_shell_console-0.8.3}/examples/git_log.example +0 -0
  10. {pygments_shell_console-0.8.2 → pygments_shell_console-0.8.3}/examples/git_show.example +0 -0
  11. {pygments_shell_console-0.8.2 → pygments_shell_console-0.8.3}/examples/status.example +0 -0
  12. {pygments_shell_console-0.8.2 → pygments_shell_console-0.8.3}/examples/test.exmpl +0 -0
  13. {pygments_shell_console-0.8.2 → pygments_shell_console-0.8.3}/examples/test.sh +0 -0
  14. {pygments_shell_console-0.8.2 → pygments_shell_console-0.8.3}/shellconsole_lexer.py +0 -0
  15. {pygments_shell_console-0.8.2 → pygments_shell_console-0.8.3}/shellconsole_style.py +0 -0
  16. {pygments_shell_console-0.8.2 → pygments_shell_console-0.8.3}/test/__init__.py +0 -0
  17. {pygments_shell_console-0.8.2 → pygments_shell_console-0.8.3}/test/test_git.py +0 -0
  18. {pygments_shell_console-0.8.2 → pygments_shell_console-0.8.3}/test/test_git_branch.py +0 -0
  19. {pygments_shell_console-0.8.2 → pygments_shell_console-0.8.3}/test/test_git_log.py +0 -0
  20. {pygments_shell_console-0.8.2 → pygments_shell_console-0.8.3}/test/test_git_merge.py +0 -0
  21. {pygments_shell_console-0.8.2 → pygments_shell_console-0.8.3}/test/test_git_show.py +0 -0
  22. {pygments_shell_console-0.8.2 → pygments_shell_console-0.8.3}/test/test_git_status.py +0 -0
  23. {pygments_shell_console-0.8.2 → pygments_shell_console-0.8.3}/test/test_prompts.py +0 -0
@@ -13,12 +13,12 @@ jobs:
13
13
  permissions:
14
14
  id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
15
15
  steps:
16
- - name: Set up Python 3.8
16
+ - name: Set up Python 3.12
17
17
  uses: actions/checkout@master
18
- - name: Set up Python 3.8
18
+ - name: Set up Python 3.12
19
19
  uses: actions/setup-python@v1
20
20
  with:
21
- python-version: 3.8
21
+ python-version: 3.12
22
22
  - name: Install pypa/build
23
23
  run: >-
24
24
  python -m
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: pygments-shell-console
3
- Version: 0.8.2
3
+ Version: 0.8.3
4
4
  Requires-Dist: pygments
5
5
  Description-Content-Type: text/markdown
6
6
 
@@ -80,8 +80,10 @@ class GitPrettyLogLexer(Lexer):
80
80
  r'(-)', # 13. Commit separator
81
81
  r'( +)', # 14. Space
82
82
  r'([0-9A-Za-zÀ-ÖØ-öø-ÿ ]*[0-9A-Za-zÀ-ÖØ-öø-ÿ]+)', # 15. Author
83
- r'( *)', # 16. Space
84
- r'((\([\w ->,:]+\))?)', # 17. Refs
83
+ r'( *)', # 16. Space
84
+ r'(\([\w ->,:]+\))?', # 17. Refs
85
+ r'( *)', # 18. Space
86
+ r'(#[^\n]*)?', # 19. Comment
85
87
  r'\n', # End
86
88
  ]
87
89
 
@@ -103,6 +105,8 @@ class GitPrettyLogLexer(Lexer):
103
105
  15: Token.Git.CommitAuthor,
104
106
  16: Whitespace,
105
107
  17: Token.Git.Refs,
108
+ 18: Whitespace,
109
+ 19: Comment,
106
110
  }
107
111
 
108
112
  def get_tokens_unprocessed(self, text):
@@ -116,12 +120,11 @@ class GitPrettyLogLexer(Lexer):
116
120
 
117
121
  ## Line is log
118
122
  if match_log:
119
- for i in range(1, len(match_log.groups())):
123
+ for i in range(1, len(match_log.groups()) + 1):
120
124
  if match_log.group(i):
121
- if self._log_tokens.get(i):
122
- yield match_log.start(i), self._log_tokens[i], match_log.group(i)
123
- else:
124
- yield match_log.start(i), Generic.Output, match_log.group(i)
125
+ token = self._log_tokens.get(i, Generic.Output)
126
+ yield match_log.start(i), token, match_log.group(i)
127
+
125
128
  yield match.end(), Whitespace, '\n'
126
129
  elif match_branch_line:
127
130
  yield match.start(), Token.Git.BranchLine, line
@@ -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.8.2"
7
+ version = "0.8.3"
8
8
  dependencies = ["pygments"]
9
9
  readme = "README.md"
10
10
 
@@ -277,3 +277,64 @@ def test_git_log_with_commit_message_commas():
277
277
  (Token.Git.CommitAuthor, "Joan Puigcerver"),
278
278
  (Token.Text.Whitespace, "\n"),
279
279
  ]
280
+
281
+ def test_git_log_with_comment_at_the_end():
282
+ lexer = ShellConsoleLexer()
283
+ text = (
284
+ "user@host:~/directory (main) $ git lg\n"
285
+ "* f853946 - (7 minutes ago) README: Afegits autors - Mar (main) # This is a comment\n"
286
+ "* 0fb88ef - (29 minutes ago) Canvis A, B i C - Joan Puigcerver # This is a comment"
287
+ )
288
+
289
+ tokens = list(lexer.get_tokens(text))
290
+
291
+ assert tokens == [
292
+ (Token.Generic.Prompt.UserHost, "user@host"),
293
+ (Token.Generic.Prompt, ":"),
294
+ (Token.Generic.Prompt.Directory, "~/directory"),
295
+ (Token.Generic.Prompt.Whitespace, " "),
296
+ (Token.Generic.Prompt.GitBranch, "(main)"),
297
+ (Token.Generic.Prompt.Whitespace, " "),
298
+ (Token.Generic.Prompt, "$"),
299
+ (Token.Generic.Prompt.Whitespace, " "),
300
+ (Token.Text, "git"),
301
+ (Token.Text.Whitespace, " "),
302
+ (Token.Text, "lg"),
303
+ (Token.Text.Whitespace, "\n"),
304
+ # First commit
305
+ (Token.Generic.Output, "*",),
306
+ (Token.Text.Whitespace, " "),
307
+ (Token.Git.CommitHash, "f853946"),
308
+ (Token.Text.Whitespace, " "),
309
+ (Token.Generic.Output, "-"),
310
+ (Token.Text.Whitespace, " "),
311
+ (Token.Git.CommitDate, "(7 minutes ago)"),
312
+ (Token.Text.Whitespace, " "),
313
+ (Token.Git.CommitMessage, "README: Afegits autors"),
314
+ (Token.Text.Whitespace, " "),
315
+ (Token.Generic.Output, "-"),
316
+ (Token.Text.Whitespace, " "),
317
+ (Token.Git.CommitAuthor, "Mar"),
318
+ (Token.Text.Whitespace, " "),
319
+ (Token.Git.Refs, "(main)"),
320
+ (Token.Text.Whitespace, " "),
321
+ (Token.Comment, "# This is a comment"),
322
+ (Token.Text.Whitespace, "\n"),
323
+ # Second commit
324
+ (Token.Generic.Output, "*"),
325
+ (Token.Text.Whitespace, " "),
326
+ (Token.Git.CommitHash, "0fb88ef"),
327
+ (Token.Text.Whitespace, " "),
328
+ (Token.Generic.Output, "-"),
329
+ (Token.Text.Whitespace, " "),
330
+ (Token.Git.CommitDate, "(29 minutes ago)"),
331
+ (Token.Text.Whitespace, " "),
332
+ (Token.Git.CommitMessage, "Canvis A, B i C"),
333
+ (Token.Text.Whitespace, " "),
334
+ (Token.Generic.Output, "-"),
335
+ (Token.Text.Whitespace, " "),
336
+ (Token.Git.CommitAuthor, "Joan Puigcerver"),
337
+ (Token.Text.Whitespace, " "),
338
+ (Token.Comment, "# This is a comment"),
339
+ (Token.Text.Whitespace, "\n"),
340
+ ]