pygments-shell-console 0.2__tar.gz → 0.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.
- {pygments_shell_console-0.2 → pygments_shell_console-0.3}/PKG-INFO +1 -1
- {pygments_shell_console-0.2 → pygments_shell_console-0.3}/git_lexer.py +12 -1
- {pygments_shell_console-0.2 → pygments_shell_console-0.3}/pyproject.toml +1 -1
- {pygments_shell_console-0.2 → pygments_shell_console-0.3}/test/test_git.py +35 -1
- {pygments_shell_console-0.2 → pygments_shell_console-0.3}/test/test_git_status.py +48 -0
- {pygments_shell_console-0.2 → pygments_shell_console-0.3}/.github/workflows/publish-to-pypi.yml +0 -0
- {pygments_shell_console-0.2 → pygments_shell_console-0.3}/.gitignore +0 -0
- {pygments_shell_console-0.2 → pygments_shell_console-0.3}/README.md +0 -0
- {pygments_shell_console-0.2 → pygments_shell_console-0.3}/examples/git_lg.example +0 -0
- {pygments_shell_console-0.2 → pygments_shell_console-0.3}/examples/git_log.example +0 -0
- {pygments_shell_console-0.2 → pygments_shell_console-0.3}/examples/git_show.example +0 -0
- {pygments_shell_console-0.2 → pygments_shell_console-0.3}/examples/status.example +0 -0
- {pygments_shell_console-0.2 → pygments_shell_console-0.3}/examples/test.exmpl +0 -0
- {pygments_shell_console-0.2 → pygments_shell_console-0.3}/examples/test.sh +0 -0
- {pygments_shell_console-0.2 → pygments_shell_console-0.3}/shellconsole_lexer.py +0 -0
- {pygments_shell_console-0.2 → pygments_shell_console-0.3}/shellconsole_style.py +0 -0
- {pygments_shell_console-0.2 → pygments_shell_console-0.3}/test/__init__.py +0 -0
- {pygments_shell_console-0.2 → pygments_shell_console-0.3}/test/test_git_branch.py +0 -0
- {pygments_shell_console-0.2 → pygments_shell_console-0.3}/test/test_git_log.py +0 -0
- {pygments_shell_console-0.2 → pygments_shell_console-0.3}/test/test_git_pretty_log.py +0 -0
- {pygments_shell_console-0.2 → pygments_shell_console-0.3}/test/test_git_show.py +0 -0
- {pygments_shell_console-0.2 → pygments_shell_console-0.3}/test/test_prompts.py +0 -0
|
@@ -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',
|
|
@@ -48,7 +49,7 @@ class GitLexer(RegexLexer):
|
|
|
48
49
|
tokens = {
|
|
49
50
|
'root': [
|
|
50
51
|
(r'\n', Whitespace),
|
|
51
|
-
(r'^hint:
|
|
52
|
+
(r'^hint:(.*?)\n', Token.Git.Hint),
|
|
52
53
|
(r'^.*$\n', Generic.Output),
|
|
53
54
|
(r'[^\n]+', Generic.Output),
|
|
54
55
|
]
|
|
@@ -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):
|
|
@@ -3,7 +3,7 @@ from pygments.token import Token
|
|
|
3
3
|
from shellconsole_lexer import ShellConsoleLexer
|
|
4
4
|
from git_lexer import GitStatusLexer
|
|
5
5
|
|
|
6
|
-
def
|
|
6
|
+
def test_git_command_with_hint():
|
|
7
7
|
lexer = ShellConsoleLexer()
|
|
8
8
|
text = (
|
|
9
9
|
"user@host:~/directory (main) $ git branch -d desc\n"
|
|
@@ -37,3 +37,37 @@ def test_git_command_whit_hint():
|
|
|
37
37
|
(Token.Git.Hint, "hint: If you are sure you want to delete it, run 'git branch -D desc'.\n"),
|
|
38
38
|
(Token.Git.Hint, "hint: Disable this message with \"git config advice.forceDeleteBranch false\".\n"),
|
|
39
39
|
]
|
|
40
|
+
|
|
41
|
+
def test_git_command_with_empty_hint():
|
|
42
|
+
lexer = ShellConsoleLexer()
|
|
43
|
+
text = (
|
|
44
|
+
"user@host:~/directory $ git init\n"
|
|
45
|
+
"hint: Using 'master' as the name for the initial branch. This default branch name\n"
|
|
46
|
+
"hint: is subject to change. To configure the initial branch name to use in all\n"
|
|
47
|
+
"hint: of your new repositories, which will suppress this warning, call:\n"
|
|
48
|
+
"hint:\n"
|
|
49
|
+
"hint: git config --global init.defaultBranch <name>\n"
|
|
50
|
+
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
tokens = list(lexer.get_tokens(text))
|
|
54
|
+
|
|
55
|
+
assert tokens == [
|
|
56
|
+
# Prompt
|
|
57
|
+
(Token.Generic.Prompt.UserHost, "user@host"),
|
|
58
|
+
(Token.Generic.Prompt, ":"),
|
|
59
|
+
(Token.Generic.Prompt.Directory, "~/directory"),
|
|
60
|
+
(Token.Text.Whitespace, " "),
|
|
61
|
+
(Token.Generic.Prompt, "$"),
|
|
62
|
+
(Token.Text.Whitespace, " "),
|
|
63
|
+
(Token.Text, "git"),
|
|
64
|
+
(Token.Text.Whitespace, " "),
|
|
65
|
+
(Token.Text, "init"),
|
|
66
|
+
(Token.Text.Whitespace, "\n"),
|
|
67
|
+
# Output
|
|
68
|
+
(Token.Git.Hint, "hint: Using 'master' as the name for the initial branch. This default branch name\n"),
|
|
69
|
+
(Token.Git.Hint, "hint: is subject to change. To configure the initial branch name to use in all\n"),
|
|
70
|
+
(Token.Git.Hint, "hint: of your new repositories, which will suppress this warning, call:\n"),
|
|
71
|
+
(Token.Git.Hint, "hint:\n"),
|
|
72
|
+
(Token.Git.Hint, "hint: git config --global init.defaultBranch <name>\n"),
|
|
73
|
+
]
|
|
@@ -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
|
+
]
|
{pygments_shell_console-0.2 → pygments_shell_console-0.3}/.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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|