pygments-shell-console 0.0.6__tar.gz → 0.1__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.
- {pygments_shell_console-0.0.6 → pygments_shell_console-0.1}/PKG-INFO +1 -1
- pygments_shell_console-0.1/examples/git_lg.example +3 -0
- pygments_shell_console-0.1/examples/git_log.example +12 -0
- pygments_shell_console-0.1/examples/git_show.example +16 -0
- {pygments_shell_console-0.0.6 → pygments_shell_console-0.1}/git_lexer.py +16 -8
- {pygments_shell_console-0.0.6 → pygments_shell_console-0.1}/pyproject.toml +1 -1
- {pygments_shell_console-0.0.6 → pygments_shell_console-0.1}/shellconsole_lexer.py +7 -4
- pygments_shell_console-0.1/test/test_git_log.py +64 -0
- pygments_shell_console-0.0.6/test/test_git_log.py → pygments_shell_console-0.1/test/test_git_pretty_log.py +58 -1
- {pygments_shell_console-0.0.6 → pygments_shell_console-0.1}/.github/workflows/publish-to-pypi.yml +0 -0
- {pygments_shell_console-0.0.6 → pygments_shell_console-0.1}/.gitignore +0 -0
- {pygments_shell_console-0.0.6 → pygments_shell_console-0.1}/README.md +0 -0
- {pygments_shell_console-0.0.6 → pygments_shell_console-0.1}/examples/status.example +0 -0
- {pygments_shell_console-0.0.6 → pygments_shell_console-0.1}/examples/test.exmpl +0 -0
- {pygments_shell_console-0.0.6 → pygments_shell_console-0.1}/examples/test.sh +0 -0
- {pygments_shell_console-0.0.6 → pygments_shell_console-0.1}/shellconsole_style.py +0 -0
- {pygments_shell_console-0.0.6 → pygments_shell_console-0.1}/test/__init__.py +0 -0
- {pygments_shell_console-0.0.6 → pygments_shell_console-0.1}/test/test_git_show.py +0 -0
- {pygments_shell_console-0.0.6 → pygments_shell_console-0.1}/test/test_git_status.py +0 -0
- {pygments_shell_console-0.0.6 → pygments_shell_console-0.1}/test/test_prompts.py +0 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
joapuiib@FP:~/01_introduccio (main) $ git log
|
|
2
|
+
commit c9fc6c856c2d52744b85a6f8d92feac496e60bd6 (HEAD -> main, tag: v1)
|
|
3
|
+
Author: Joan Puigcerver <j.puigcerveribanez@edu.gva.es>
|
|
4
|
+
Date: Mon Oct 16 11:43:20 2023 +0200
|
|
5
|
+
|
|
6
|
+
Added another line to README.md
|
|
7
|
+
|
|
8
|
+
commit 8e702933d5dbec9ee71100a1599ae4491085e1aa (tag: v2)
|
|
9
|
+
Author: Joan Puigcerver <j.puigcerveribanez@edu.gva.es>
|
|
10
|
+
Date: Fri Oct 13 16:06:59 2023 +0200
|
|
11
|
+
|
|
12
|
+
Added Readme.md
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
joapuiib@FP:~/01_introduccio (main) $ git show 8e70293
|
|
2
|
+
commit 8e702933d5dbec9ee71100a1599ae4491085e1aa (HEAD -> main)
|
|
3
|
+
Author: Joan Puigcerver Ibáñez <j.puigcerveribanez@edu.gva.es>
|
|
4
|
+
Date: Fri Oct 13 16:06:59 2023 +0200
|
|
5
|
+
|
|
6
|
+
Added README.md
|
|
7
|
+
|
|
8
|
+
diff --git a/README.md b/README.md
|
|
9
|
+
new file mode 100644
|
|
10
|
+
index 0000000..6d747b3
|
|
11
|
+
--- /dev/null
|
|
12
|
+
+++ b/README.md
|
|
13
|
+
@@ -0,0 +1,2 @@
|
|
14
|
+
+# 01 - Introducció a Git
|
|
15
|
+
+Estem aprenent a utilitzar Git!
|
|
16
|
+
-Deletion
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from pygments.lexer import Lexer
|
|
4
4
|
from pygments.lexer import RegexLexer, ExtendedRegexLexer, include, bygroups, \
|
|
5
|
-
default, using, line_re, do_insertions
|
|
5
|
+
default, using, line_re, do_insertions, inherit
|
|
6
6
|
from pygments.token import Token, Punctuation, Whitespace, \
|
|
7
7
|
Text, Comment, Operator, Keyword, Name, String, Number, Generic
|
|
8
8
|
from pygments.lexers.diff import DiffLexer
|
|
@@ -32,7 +32,7 @@ STANDARD_TYPES.update({
|
|
|
32
32
|
Token.Git.Refs.Branch: 'git-b',
|
|
33
33
|
})
|
|
34
34
|
|
|
35
|
-
class
|
|
35
|
+
class GitPrettyLogLexer(Lexer):
|
|
36
36
|
name = "Git"
|
|
37
37
|
aliases = ["git"]
|
|
38
38
|
filenames = ['*.git']
|
|
@@ -54,10 +54,10 @@ class GitLogLexer(Lexer):
|
|
|
54
54
|
r'( +)', # 12. Space
|
|
55
55
|
r'(-)', # 13. Commit separator
|
|
56
56
|
r'( +)', # 14. Space
|
|
57
|
-
r'([0-9A-Za-zÀ-ÖØ-öø-ÿ ]+)', # 15. Author
|
|
58
|
-
r'(
|
|
59
|
-
r'((\([\w ->,:]+\))?)',
|
|
60
|
-
r'
|
|
57
|
+
r'([0-9A-Za-zÀ-ÖØ-öø-ÿ ]*[0-9A-Za-zÀ-ÖØ-öø-ÿ]+)', # 15. Author
|
|
58
|
+
r'( *)', # 16. Space
|
|
59
|
+
r'((\([\w ->,:]+\))?)', # 17. Refs
|
|
60
|
+
r'\n', # End
|
|
61
61
|
]
|
|
62
62
|
|
|
63
63
|
# Combine the regex patterns into a single pattern
|
|
@@ -142,11 +142,10 @@ class GitStatusLexer(RegexLexer):
|
|
|
142
142
|
],
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
class
|
|
145
|
+
class GitLogLexer(RegexLexer):
|
|
146
146
|
tokens = {
|
|
147
147
|
'root': [
|
|
148
148
|
(r'^\n', Whitespace),
|
|
149
|
-
(r'^diff .*\n', using(DiffLexer), 'diff'),
|
|
150
149
|
(r'^(commit [0-9a-f]+)', Token.Git.Show.Header, 'header'),
|
|
151
150
|
(r'^.*\n', Generic.Output),
|
|
152
151
|
],
|
|
@@ -160,6 +159,15 @@ class GitShowLexer(RegexLexer):
|
|
|
160
159
|
(r'[\w/_-]+', Token.Git.Refs.Branch),
|
|
161
160
|
(r'\n', Whitespace, '#pop'),
|
|
162
161
|
],
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
class GitShowLexer(GitLogLexer):
|
|
166
|
+
tokens = {
|
|
167
|
+
'root': [
|
|
168
|
+
(r'^diff .*\n', using(DiffLexer), 'diff'),
|
|
169
|
+
inherit
|
|
170
|
+
],
|
|
163
171
|
'diff': [
|
|
164
172
|
(r'^.*\n', using(DiffLexer)),
|
|
165
173
|
],
|
|
@@ -8,7 +8,7 @@ from pygments.token import Token, Punctuation, Whitespace, \
|
|
|
8
8
|
from pygments.lexers.diff import DiffLexer
|
|
9
9
|
from pygments.lexers.shell import BashLexer
|
|
10
10
|
from pygments.lexers.diff import DiffLexer
|
|
11
|
-
from git_lexer import GitLogLexer, GitStatusLexer, GitShowLexer
|
|
11
|
+
from git_lexer import GitLogLexer, GitPrettyLogLexer, GitStatusLexer, GitShowLexer
|
|
12
12
|
from pygments.token import STANDARD_TYPES
|
|
13
13
|
|
|
14
14
|
import re
|
|
@@ -75,7 +75,8 @@ class ShellConsoleLexer(Lexer):
|
|
|
75
75
|
def get_tokens_unprocessed(self, text):
|
|
76
76
|
innerlexer = self._innerLexerCls(**self.options)
|
|
77
77
|
difflexer = DiffLexer()
|
|
78
|
-
|
|
78
|
+
git_log_lexer = GitLogLexer()
|
|
79
|
+
git_pretty_log_lexer = GitPrettyLogLexer()
|
|
79
80
|
gitstatuslexer = GitStatusLexer()
|
|
80
81
|
gitshowlexer = GitShowLexer()
|
|
81
82
|
|
|
@@ -154,8 +155,10 @@ class ShellConsoleLexer(Lexer):
|
|
|
154
155
|
else:
|
|
155
156
|
if 'diff' in curcode:
|
|
156
157
|
custom_lexer = difflexer
|
|
157
|
-
elif curcode.startswith('git lg'):
|
|
158
|
-
custom_lexer =
|
|
158
|
+
elif curcode.startswith('git lg') or curcode.startswith('git log --graph'):
|
|
159
|
+
custom_lexer = git_pretty_log_lexer
|
|
160
|
+
elif curcode.startswith('git log'):
|
|
161
|
+
custom_lexer = git_log_lexer
|
|
159
162
|
elif curcode.startswith('git status'):
|
|
160
163
|
custom_lexer = gitstatuslexer
|
|
161
164
|
elif curcode.startswith('git show'):
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
from pygments.token import Token
|
|
3
|
+
from shellconsole_lexer import ShellConsoleLexer
|
|
4
|
+
from git_lexer import GitStatusLexer
|
|
5
|
+
|
|
6
|
+
def test_git_show():
|
|
7
|
+
lexer = ShellConsoleLexer()
|
|
8
|
+
text = (
|
|
9
|
+
"user@host:~/directory (main) $ git show\n"
|
|
10
|
+
"commit c9fc6c856c2d52744b85a6f8d92feac496e60bd6 (HEAD -> main, tag: v1)\n"
|
|
11
|
+
"Author: Author <author@localhost>\n"
|
|
12
|
+
"Date: Mon Oct 16 11:43:20 2023 +0200\n"
|
|
13
|
+
"\n"
|
|
14
|
+
" Added another line to README.md\n"
|
|
15
|
+
"\n"
|
|
16
|
+
"commit 8e702933d5dbec9ee71100a1599ae4491085e1aa\n"
|
|
17
|
+
"Author: Author <author@localhost>\n"
|
|
18
|
+
"Date: Fri Oct 13 16:06:59 2023 +0200\n"
|
|
19
|
+
"\n"
|
|
20
|
+
" Added README.md\n"
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
tokens = list(lexer.get_tokens(text))
|
|
24
|
+
|
|
25
|
+
assert tokens == [
|
|
26
|
+
(Token.Generic.Prompt.UserHost, "user@host"),
|
|
27
|
+
(Token.Generic.Prompt, ":"),
|
|
28
|
+
(Token.Generic.Prompt.Directory, "~/directory"),
|
|
29
|
+
(Token.Text.Whitespace, " "),
|
|
30
|
+
(Token.Generic.Prompt.GitBranch, "(main)"),
|
|
31
|
+
(Token.Text.Whitespace, " "),
|
|
32
|
+
(Token.Generic.Prompt, "$"),
|
|
33
|
+
(Token.Text.Whitespace, " "),
|
|
34
|
+
(Token.Text, "git"),
|
|
35
|
+
(Token.Text.Whitespace, " "),
|
|
36
|
+
(Token.Text, "show"),
|
|
37
|
+
(Token.Text.Whitespace, "\n"),
|
|
38
|
+
# First commit
|
|
39
|
+
(Token.Git.Show.Header, "commit c9fc6c856c2d52744b85a6f8d92feac496e60bd6"),
|
|
40
|
+
(Token.Text.Whitespace, " "),
|
|
41
|
+
(Token.Git.Show.Header, "("),
|
|
42
|
+
(Token.Git.Refs.Head, "HEAD"),
|
|
43
|
+
(Token.Text.Whitespace, " "),
|
|
44
|
+
(Token.Git.Show.Header, "->"),
|
|
45
|
+
(Token.Text.Whitespace, " "),
|
|
46
|
+
(Token.Git.Refs.Branch, "main"),
|
|
47
|
+
(Token.Git.Show.Header, ","),
|
|
48
|
+
(Token.Text.Whitespace, " "),
|
|
49
|
+
(Token.Git.Refs.Tag, "tag: v1"),
|
|
50
|
+
(Token.Git.Show.Header, ")"),
|
|
51
|
+
(Token.Text.Whitespace, "\n"),
|
|
52
|
+
(Token.Generic.Output, "Author: Author <author@localhost>\n"),
|
|
53
|
+
(Token.Generic.Output, "Date: Mon Oct 16 11:43:20 2023 +0200\n"),
|
|
54
|
+
(Token.Text.Whitespace, "\n"),
|
|
55
|
+
(Token.Generic.Output, " Added another line to README.md\n"),
|
|
56
|
+
(Token.Text.Whitespace, "\n"),
|
|
57
|
+
# Second commit
|
|
58
|
+
(Token.Git.Show.Header, "commit 8e702933d5dbec9ee71100a1599ae4491085e1aa"),
|
|
59
|
+
(Token.Text.Whitespace, "\n"),
|
|
60
|
+
(Token.Generic.Output, "Author: Author <author@localhost>\n"),
|
|
61
|
+
(Token.Generic.Output, "Date: Fri Oct 13 16:06:59 2023 +0200\n"),
|
|
62
|
+
(Token.Text.Whitespace, "\n"),
|
|
63
|
+
(Token.Generic.Output, " Added README.md\n"),
|
|
64
|
+
]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import pytest
|
|
2
2
|
from pygments.token import Token
|
|
3
3
|
from shellconsole_lexer import ShellConsoleLexer
|
|
4
|
-
from git_lexer import
|
|
4
|
+
from git_lexer import GitPrettyLogLexer
|
|
5
5
|
|
|
6
6
|
def test_full_git_log():
|
|
7
7
|
lexer = ShellConsoleLexer()
|
|
@@ -163,3 +163,60 @@ def test_git_log_with_other_command():
|
|
|
163
163
|
(Token.Literal.String.Single, "'Hello, world!'"),
|
|
164
164
|
(Token.Text.Whitespace, "\n"),
|
|
165
165
|
]
|
|
166
|
+
|
|
167
|
+
def test_simple_git_log():
|
|
168
|
+
lexer = ShellConsoleLexer()
|
|
169
|
+
text = (
|
|
170
|
+
"user@host:~/directory (main) $ git lg\n"
|
|
171
|
+
"* f853946 - (7 minutes ago) README: Afegits autors - Mar (main)\n"
|
|
172
|
+
"* 0fb88ef - (29 minutes ago) 1. Primer commit - Joan Puigcerver"
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
tokens = list(lexer.get_tokens(text))
|
|
176
|
+
|
|
177
|
+
assert tokens == [
|
|
178
|
+
(Token.Generic.Prompt.UserHost, "user@host"),
|
|
179
|
+
(Token.Generic.Prompt, ":"),
|
|
180
|
+
(Token.Generic.Prompt.Directory, "~/directory"),
|
|
181
|
+
(Token.Text.Whitespace, " "),
|
|
182
|
+
(Token.Generic.Prompt.GitBranch, "(main)"),
|
|
183
|
+
(Token.Text.Whitespace, " "),
|
|
184
|
+
(Token.Generic.Prompt, "$"),
|
|
185
|
+
(Token.Text.Whitespace, " "),
|
|
186
|
+
(Token.Text, "git"),
|
|
187
|
+
(Token.Text.Whitespace, " "),
|
|
188
|
+
(Token.Text, "lg"),
|
|
189
|
+
(Token.Text.Whitespace, "\n"),
|
|
190
|
+
# First commit
|
|
191
|
+
(Token.Generic.Output, "*",),
|
|
192
|
+
(Token.Text.Whitespace, " "),
|
|
193
|
+
(Token.Git.CommitHash, "f853946"),
|
|
194
|
+
(Token.Text.Whitespace, " "),
|
|
195
|
+
(Token.Generic.Output, "-"),
|
|
196
|
+
(Token.Text.Whitespace, " "),
|
|
197
|
+
(Token.Git.CommitDate, "(7 minutes ago)"),
|
|
198
|
+
(Token.Text.Whitespace, " "),
|
|
199
|
+
(Token.Git.CommitMessage, "README: Afegits autors"),
|
|
200
|
+
(Token.Text.Whitespace, " "),
|
|
201
|
+
(Token.Generic.Output, "-"),
|
|
202
|
+
(Token.Text.Whitespace, " "),
|
|
203
|
+
(Token.Git.CommitAuthor, "Mar"),
|
|
204
|
+
(Token.Text.Whitespace, " "),
|
|
205
|
+
(Token.Git.Refs, "(main)"),
|
|
206
|
+
(Token.Text.Whitespace, "\n"),
|
|
207
|
+
# Second commit
|
|
208
|
+
(Token.Generic.Output, "*"),
|
|
209
|
+
(Token.Text.Whitespace, " "),
|
|
210
|
+
(Token.Git.CommitHash, "0fb88ef"),
|
|
211
|
+
(Token.Text.Whitespace, " "),
|
|
212
|
+
(Token.Generic.Output, "-"),
|
|
213
|
+
(Token.Text.Whitespace, " "),
|
|
214
|
+
(Token.Git.CommitDate, "(29 minutes ago)"),
|
|
215
|
+
(Token.Text.Whitespace, " "),
|
|
216
|
+
(Token.Git.CommitMessage, "1. Primer commit"),
|
|
217
|
+
(Token.Text.Whitespace, " "),
|
|
218
|
+
(Token.Generic.Output, "-"),
|
|
219
|
+
(Token.Text.Whitespace, " "),
|
|
220
|
+
(Token.Git.CommitAuthor, "Joan Puigcerver"),
|
|
221
|
+
(Token.Text.Whitespace, "\n"),
|
|
222
|
+
]
|
{pygments_shell_console-0.0.6 → pygments_shell_console-0.1}/.github/workflows/publish-to-pypi.yml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|