Skip to content

Commit

Permalink
[Diff] Embed Git Diff from Git Log
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelblyons authored Dec 21, 2024
1 parent 3685f51 commit 4ee85d3
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 88 deletions.
52 changes: 3 additions & 49 deletions Git Formats/Git Log.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,9 @@ contexts:
- match: ','
scope: punctuation.separator.sequence.git.log
- match: (?={{diff_begin}})
embed: scope:source.shell.bash
escape: $
- match: (?=^index\s)
push: extended-patch-headers
embed: Git Diff.sublime-syntax#diffs
embed_scope: source.diff.git
escape: (?={{commit_begin}})

commit-header:
# All header attributes are mappings of `key: value` format.
Expand All @@ -72,48 +71,3 @@ contexts:
# https://github.com/SublimeTextIssues/Core/issues/2395
- match: ^
push: Git Commit Message.sublime-syntax

extended-patch-headers:
# https://git-scm.com/docs/git-show#_generating_patch_text_with_p
- meta_scope: meta.diff.header.extended.git.log
- match: ^(index)\s+
captures:
1: keyword.context.git.log
push: index
- match: ^((?:new|deleted)\s+file\s+)?(mode)\s+
captures:
1: keyword.context.git.log
2: keyword.context.git.log
push: mode
- match: ^((?:dis)?similarity\s+index)\s+
captures:
1: keyword.context.git.log
push: similarity-index
- match: ^((?:copy|move)\s+(?:from|to))\s+
captures:
1: keyword.context.git.log
push: copy-or-move
- match: ^
pop: 1
embed: scope:source.diff
escape: '{{commit_or_diff_begin}}'

index:
- include: Git Common.sublime-syntax#commit
- include: mode

mode:
- include: Git Common.sublime-syntax#eol-pop
- match: ',|\.\.'
scope: punctuation.separator.sequence.git.log
- match: '[0-7]{6}'
scope: meta.number.integer.octal.git.log constant.numeric.value.git.log

similarity-index:
- include: Git Common.sublime-syntax#eol-pop
- match: \d+
scope: meta.number.integer.decimal.git.log constant.numeric.value.git.log

copy-or-move:
- include: Git Common.sublime-syntax#eol-pop
- include: Git Link.sublime-syntax#expect-path
111 changes: 72 additions & 39 deletions Git Formats/tests/syntax_test_git_log
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,10 @@ Date: Tue Aug 24 13:44:17 2021 -0400
[TypeScript] [TSX] Fix arrow function type parameter tests for TSX. (#2987)

diff --git a/JavaScript/TypeScript.sublime-syntax b/JavaScript/TypeScript.sublime-syntax
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.shell
# ^ - source.shell
#^^^ source.shell meta.function-call.identifier variable.function
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.diff.git
#^^^ meta.function-call.identifier variable.function
# ^^ punctuation.definition.parameter
# ^^^ variable.parameter.option
# ^^^ variable.parameter
index ae1b1061..c1a585d0 100644
--- a/JavaScript/TypeScript.sublime-syntax
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.diff meta.diff.header meta.header.from-file
Expand All @@ -103,48 +102,82 @@ index ae1b1061..c1a585d0 100644
- # branch:
- # - ts-old-type-assertion
diff --git a/JavaScript/tests/syntax_test_typescript_not_tsx.ts b/JavaScript/tests/syntax_test_typescript_not_tsx.ts
#^^^ source.shell meta.function-call.identifier variable.function
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.header.diff meta.toc-list.git
#^^^ meta.function-call.identifier.git variable.function.diff
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.git
# ^^^^^ variable.parameter.diff
# ^^ punctuation.definition.parameter.diff
# ^ variable.parameter.source.diff
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.path.diff string.unquoted.git
# ^ punctuation.separator.path.diff
# ^ punctuation.separator.path.diff
# ^ punctuation.separator.path.diff
# ^ variable.parameter.source.diff
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.path.diff string.unquoted.git
# ^ punctuation.separator.path.diff
# ^ punctuation.separator.path.diff
# ^ punctuation.separator.path.diff
index c90bfab4,c90bfab4..e9338c70 100644
#^^^^ keyword.context.git.log
# ^^^^^^^^ constant.other.hash
# ^ punctuation.separator.sequence.git.log
# ^^^^^^^^ constant.other.hash
# ^^ punctuation.separator.sequence.git.log
# ^^^^^^^^ constant.other.hash
# ^^^^^^ meta.number.integer.octal.git constant.numeric.value.git.log
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.diff.header.extended.git.log
mode 012345,676543..701532
#^^^ keyword.context.git.log
# ^^^^^^ meta.number.integer.octal.git constant.numeric.value.git.log
# ^ punctuation.separator.sequence.git.log
# ^^^^^^ meta.number.integer.octal.git constant.numeric.value.git.log
# ^^ punctuation.separator.sequence.git.log
# ^^^^^^ meta.number.integer.octal.git constant.numeric.value.git.log
new file mode 012345
#^^^^^^^^^^^^ keyword.context.git.log
# ^^^^^^ meta.number.integer.octal.git constant.numeric.value.git.log
deleted file mode 012345,676543
#^^^^^^^^^^^^^^^^ keyword.context.git.log
# ^^^^^^ meta.number.integer.octal.git constant.numeric.value.git.log
# ^ punctuation.separator.sequence.git.log
# ^^^^^^ meta.number.integer.octal.git constant.numeric.value.git.log
similarity index 983489374
#^^^^^^^^^^^^^^^ keyword.context.git.log
# ^^^^^^^^^ meta.number.integer.decimal.git constant.numeric.value.git.log
dissimilarity index 72637263
#^^^^^^^^^^^^^^^^^^ keyword.context.git.log
# ^^^^^^^^ meta.number.integer.decimal.git constant.numeric.value.git.log
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.diff.git meta.block.header.diff
#^^^^ keyword.other.diff
# ^^^^^^^^ constant.other.hash.git
# ^ punctuation.separator.sequence.git
# ^^^^^^^^ constant.other.hash.git
# ^^ punctuation.separator.range.git
# ^^^^^^^^ constant.other.hash.git
# ^^^^^^ meta.number.integer.octal.diff constant.numeric.value.diff
mode 100644,100755..755
#^^^^^^^^^^^^^^^^^^^^^^ source.diff.git meta.block.header.diff
#^^^ keyword.other.diff
# ^^^^^^ meta.number.integer.octal.diff constant.numeric.value.diff
# ^ punctuation.separator.sequence.git
# ^^^^^^ meta.number.integer.octal.diff constant.numeric.value.diff storage.modifier.executable.diff
# ^^ punctuation.separator.range.git
# ^^^ meta.number.integer.octal.diff constant.numeric.value.diff storage.modifier.executable.diff
new file mode 644
#^^^^^^^^^^^^^^^^ source.diff.git meta.block.header.diff markup.inserted.diff
# ^^^ meta.number.integer.octal.diff constant.numeric.value.diff
deleted file mode 644,755
#^^^^^^^^^^^^^^^^^^^^^^^^ source.diff.git meta.block.header.diff markup.deleted.diff
# ^^^ meta.number.integer.octal.diff constant.numeric.value.diff
# ^ punctuation.separator.sequence.git
# ^^^ meta.number.integer.octal.diff constant.numeric.value.diff storage.modifier.executable.diff
similarity index 89%
#^^^^^^^^^^^^^^^^^^^ source.diff.git meta.block.header.diff
#^^^^^^^^^^^^^^^ keyword.other.diff
# ^^^ meta.number.integer.decimal.git
# ^^ constant.numeric.value.git
# ^ constant.numeric.suffix.git
dissimilarity index 4%
#^^^^^^^^^^^^^^^^^^^^^ source.diff.git meta.block.header.diff
#^^^^^^^^^^^^^^^^^^ keyword.other.diff
# ^^ meta.number.integer.decimal.git
# ^ constant.numeric.value.git
# ^ constant.numeric.suffix.git
copy from JavaScript/tests/syntax_test_typescript_not_tsx.ts
#^^^^^^^^ keyword.context.git.log
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.diff.git meta.block.header.diff
#^^^^^^^^ keyword.other.diff
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.path.git string.unquoted.git
# ^ punctuation.separator.path.diff
# ^ punctuation.separator.path.diff
move to JavaScript/tests/syntax_test_typescript_not_tsx.ts
#^^^^^^ keyword.context.git.log
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.diff.git meta.block.header.diff
#^^^^^^ keyword.other.diff
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.path.git string.unquoted.git
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.diff.header.extended.git.log
# ^ punctuation.separator.path.diff
# ^ punctuation.separator.path.diff
--- a/JavaScript/tests/syntax_test_typescript_not_tsx.ts
#<- - meta.diff.header.extended
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.header.diff meta.diff.header.from-file meta.header.from-file.diff
#^^ punctuation.definition.from-file.diff
# ^ punctuation.separator.path.diff
# ^ punctuation.separator.path.diff
# ^ punctuation.separator.path.diff
+++ b/JavaScript/tests/syntax_test_typescript_not_tsx.ts
#^^ source.diff meta.diff.header meta.header.to-file punctuation.definition.to-file
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.header.diff meta.diff.header.to-file meta.header.to-file.diff
#^^ punctuation.definition.to-file.diff
# ^ punctuation.separator.path.diff
# ^ punctuation.separator.path.diff
# ^ punctuation.separator.path.diff
@@ -25,3 +25,12 @@
let strLength: number = (<string>someValue).length; // </string>
// ^^^^^^^^ meta.assertion - meta.tag
Expand Down

0 comments on commit 4ee85d3

Please sign in to comment.