userdiff: add funcname regex and wordregex for typescript language
PATCH 1/1 userdiff: add funcname regex and wordregex for typescript language
This patch adds a builtin driver for typescript language supporting regex for both function name and words. Also updates the .gitattributes.txt to reflect this.
gitattributes: add typescript language to hunk headers support
t4034: add tests for typescript word_regex
t4018: add tests for typescript funcname regex
userdiff: add funcname regex and wordregex for typescript language
---
Index: userdiff.c
userdiff.c +16 -0
@@ -297,6 +297,22 @@ "|([^][)(}{[ \t])+"),PATTERNS ("tex" ,"^(\\\\((sub)*section|chapter|part)\\*{0,1}\\{.*)$" ,"\\\\[a-zA-Z@]+|\\\\.|([a-zA-Z0-9]|[^\x01-\x7f])+" ), +PATTERNS ("typescript" , +"^[ \t]*((enum|interface|type)[ \t]+([a-zA-Z][a-zA-Z0-9]*)+.*)$\n" +/* Method definitions */ +"^[ \t]*[a-z]+[ \t]+([A-Za-z_][A-Za-z_0-9]*)+([ \t]*=[ \t]*(function)?)?([ \t]*[A-Za-z_<>&][?&<>|.,A-Za-z_]*[ \t]*)*[ \t]*\\([^;]*$" , +/* -- */ +"[a-zA-Z_][a-zA-Z0-9_]*" +/* Integers and floats */ +"|[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?" +/* Binary */ +"|0[bB][01]+" +/* Hexadecimals */ +"|0[xX][0-9a-fA-F]+" +/* Floats starting with a decimal point */ +"|[-+]?([0-9]*\\.?[0-9]+|[0-9]+\\.?[0-9]*)([eE][-+]?[0-9]+)?" +/* Operators */ +"[-+*/%&|^!=<>]=?|===|!==|<<=?|>>=?|&&|\\|\\||\\?\\?|\\+\\+|--|~" ), { "default", NULL, NULL, -1, { NULL, 0 } }, };#undef PATTERNS
Index: t/t4018/typescript-arrow-function
t/t4018/typescript-arrow-function new file +4 -0
@@ -0,0 +1,4 @@ +const RIGHT = (one) => { + someMethodCall(); + return ChangeMe; +}
Index: t/t4018/typescript-class-member-function
t/t4018/typescript-class-member-function new file +7 -0
@@ -0,0 +1,7 @@ +class Test { + var one; + function RIGHT(two: string) { + someMethodCall(); + return ChangeMe; + } +}
Index: t/t4018/typescript-enum
t/t4018/typescript-enum new file +6 -0
@@ -0,0 +1,6 @@ +enum RIGHT { + ONE = 1, + TWO, + THREE, + ChangeMe +}
Index: t/t4018/typescript-function
t/t4018/typescript-function new file +4 -0
@@ -0,0 +1,4 @@ +function RIGHT<Type implements AnotherType>(one: number): Type { + someMethodCall(); + return ChangeMe; +}
Index: t/t4018/typescript-function-assignment
t/t4018/typescript-function-assignment new file +4 -0
@@ -0,0 +1,4 @@ +const RIGHT = function(one: number): Type { + someMethodCall(); + return ChangeMe; +}
Index: t/t4018/typescript-interface
t/t4018/typescript-interface new file +4 -0
@@ -0,0 +1,4 @@ +interface RIGHT { + one?: string; + [propName: ChangeMe]: any; +}
Index: t/t4018/typescript-type
t/t4018/typescript-type new file +4 -0
@@ -0,0 +1,4 @@ +type RIGHT = { + one: number, + ChangeMe: CustomType +}
Index: t/t4034-diff-words.sh
t/t4034-diff-words.sh +1 -0
@@ -338,6 +338,7 @@ test_language_driver ruby test_language_driver scheme test_language_driver tex +test_language_driver typescript test_expect_success 'word-diff with diff.sbe' ' cat >pre <<-\EOF &&
Index: t/t4034/typescript/expect
t/t4034/typescript/expect new file +57 -0
57 lines not on this page · raw message
Index: t/t4034/typescript/post
t/t4034/typescript/post new file +16 -0
@@ -0,0 +1,16 @@ +log("Hello World?") +(1) (-1e10) (0xabcdef) u'y' +!x ~x x++ x-- x*y x&y +x*y x/y x%y +x+y x-y +x<<y x>>y +x<y x<=y x>y x>=y +x==y x!=y +x&y +x^y +x|y +x&&y +x||y +x?y:z +x=y x+=y x-=y x*=y x/=y x%=y x<<=y x>>=y x&=y x^=y x|=y +x,y
Index: t/t4034/typescript/pre
t/t4034/typescript/pre new file +16 -0
@@ -0,0 +1,16 @@ +log("Hello World!\n") +1 -1e10 0xabcdef 'x' +!a ~a a++ a-- a*b a&b +a*b a/b a%b +a+b a-b +a<<b a>>b +a<b a<=b a>b a>=b +a==b a!=b +a&b +a^b +a|b +a&&b +a||b +a?b:z +a=b a+=b a-=b a*=b a/=b a%=b a<<=b a>>=b a&=b a^=b a|=b +a,y
Index: Documentation/gitattributes.txt
Documentation/gitattributes.txt +2 -0
@@ -902,6 +902,8 @@ - `tex` suitable for source code for LaTeX documents. +- `typescript` suitable for source code for TypeScript language. + Customizing word diff ^^^^^^^^^^^^^^^^^^^^^
Quoted 1 line · Utsav Parmar
This patch adds a builtin driver for typescript language supporting regex for both function name and words. Also updates the
.gitattributes.txtto reflect this.
Please be mindful that we typically wrap commit messages at 72 columns per line. Furthermore, we don't typically say "This patch", but rather use an imperative style. So instead of saying "This patch adds a biultin driver", we'd say "Add a builtin driver".
Quoted 4 lines
gitattributes: add typescript language to hunk headers support
t4034: add tests for typescriptword_regex
t4018: add tests for typescript funcname regex
userdiff: add funcname regex and wordregex for typescript language
We don't usually provide such bulleted-list-style changes for each of the files. In this case, it shoul be fine to say something "Add tests and documentation for the new driver".
Last but not least, this message is missing your signoff.
I would recommend you to read "Documentation/MyFirstContribution.txt", which explains all of this.
I can't really say much regarding the remainder of your changes given that I'm neither familiar with "userdiff.c" nor with TypeScript. I hope that others can chime in here.
Patrick
Quoted 238 lines
---
Index:userdiff.cuserdiff.c +16
-0@@ -297,6 +297,22 @@ "|([^][)(}{[ \t])+"),PATTERNS ("tex" ,"^(\\\\((sub)*section|chapter|part)\\*{0,1}\\{.*)$" ,"\\\\[a-zA-Z@]+|\\\\.|([a-zA-Z0-9]|[^\x01-\x7f])+" ), +PATTERNS ("typescript" , +"^[ \t]*((enum|interface|type)[ \t]+([a-zA-Z][a-zA-Z0-9]*)+.*)$\n" +/* Method definitions */ +"^[ \t]*[a-z]+[ \t]+([A-Za-z_][A-Za-z_0-9]*)+([ \t]*=[ \t]*(function)?)?([ \t]*[A-Za-z_<>&][?&<>|.,A-Za-z_]*[ \t]*)*[ \t]*\\([^;]*$" , +/* -- */ +"[a-zA-Z_][a-zA-Z0-9_]*" +/* Integers and floats */ +"|[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?" +/* Binary */ +"|0[bB][01]+" +/* Hexadecimals */ +"|0[xX][0-9a-fA-F]+" +/* Floats starting with a decimal point */ +"|[-+]?([0-9]*\\.?[0-9]+|[0-9]+\\.?[0-9]*)([eE][-+]?[0-9]+)?" +/* Operators */ +"[-+*/%&|^!=<>]=?|===|!==|<<=?|>>=?|&&|\\|\\||\\?\\?|\\+\\+|--|~" ), { "default", NULL, NULL, -1, { NULL, 0 } }, };#undef PATTERNSIndex: t/t4018/typescript-arrow-function
t/t4018/typescript-arrow-function new file +4
-0@@ -0,0 +1,4 @@ +const RIGHT = (one) => { + someMethodCall(); + return ChangeMe; +}Index: t/t4018/typescript-class-member-function
t/t4018/typescript-class-member-function new file +7
-0@@ -0,0 +1,7 @@ +class Test { + var one; + function RIGHT(two: string) { + someMethodCall(); + return ChangeMe; + } +}Index: t/t4018/typescript-enum
t/t4018/typescript-enum new file +6
-0@@ -0,0 +1,6 @@ +enum RIGHT { + ONE = 1, + TWO, + THREE, + ChangeMe +}Index: t/t4018/typescript-function
t/t4018/typescript-function new file +4
-0@@ -0,0 +1,4 @@ +function RIGHT<Type implements AnotherType>(one: number): Type { + someMethodCall(); + return ChangeMe; +}Index: t/t4018/typescript-function-assignment
t/t4018/typescript-function-assignment new file +4
-0@@ -0,0 +1,4 @@ +const RIGHT = function(one: number): Type { + someMethodCall(); + return ChangeMe; +}Index: t/t4018/typescript-interface
t/t4018/typescript-interface new file +4
-0@@ -0,0 +1,4 @@ +interface RIGHT { + one?: string; + [propName: ChangeMe]: any; +}Index: t/t4018/typescript-type
t/t4018/typescript-type new file +4
-0@@ -0,0 +1,4 @@ +type RIGHT = { + one: number, + ChangeMe: CustomType +}Index:
t/t4034-diff-words.sht/t4034-diff-words.sh +1
-0@@ -338,6 +338,7 @@ test_language_driver ruby test_language_driver scheme test_language_driver tex +test_language_driver typescript test_expect_success 'word-diff with diff.sbe' ' cat >pre <<-\EOF &&Index: t/t4034/typescript/expect
t/t4034/typescript/expect new file +57
-0@@ -0,0 +1,57 @@ +<BOLD>diff --git a/pre b/post<RESET> +<BOLD>index e4a51a2..9c56465 100644<RESET> +<BOLD>--- a/pre<RESET> +<BOLD>+++ b/post<RESET> +<CYAN>@@ -1,16 +1,16 @@<RESET> +log("Hello World<RED>!\n<RESET><GREEN>?<RESET>") +<GREEN>(<RESET>1<GREEN>) (<RESET>-1e10<GREEN>) (<RESET>0xabcdef<GREEN>) u<RESET>'<RED>x<RESET><GREEN>y<RESET>' +!<RED>a<RESET><GREEN>x<RESET> ~<RED>a a<RESET><GREEN>x x<RESET>++ <RED>a<RESET><GREEN>x<RESET>-- <RED>a<RESET><GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>&<RED>b +<RESET> +<RED>a<RESET><GREEN>y +<RESET> +<GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>/<RED>b a<RESET><GREEN>y x<RESET>%<RED>b +<RESET> +<RED>a<RESET><GREEN>y +<RESET> +<GREEN>x<RESET>+<RED>b a<RESET><GREEN>y x<RESET>-<RED>b +<RESET> +<RED>a<RESET><GREEN>y +<RESET> +<GREEN>x<RESET><<<RED>b a<RESET><GREEN>y x<RESET>>><RED>b +<RESET> +<RED>a<RESET><GREEN>y +<RESET> +<GREEN>x<RESET><<RED>b a<RESET><GREEN>y x<RESET><=<RED>b a<RESET><GREEN>y x<RESET>><RED>b a<RESET><GREEN>y x<RESET>>=<RED>b +<RESET> +<RED>a<RESET><GREEN>y +<RESET> +<GREEN>x<RESET>==<RED>b a<RESET><GREEN>y x<RESET>!=<RED>b +<RESET> +<RED>a<RESET><GREEN>y +<RESET> +<GREEN>x<RESET>&<RED>b +<RESET> +<RED>a<RESET><GREEN>y +<RESET> +<GREEN>x<RESET>^<RED>b +<RESET> +<RED>a<RESET><GREEN>y +<RESET> +<GREEN>x<RESET>|<RED>b +<RESET> +<RED>a<RESET><GREEN>y +<RESET> +<GREEN>x<RESET>&&<RED>b +<RESET> +<RED>a<RESET><GREEN>y +<RESET> +<GREEN>x<RESET>||<RED>b +<RESET> +<RED>a<RESET><GREEN>y +<RESET> +<GREEN>x<RESET>?<RED>b<RESET><GREEN>y<RESET>:z +<RED>a<RESET><GREEN>x<RESET>=<RED>b a<RESET><GREEN>y x<RESET>+=<RED>b a<RESET><GREEN>y x<RESET>-=<RED>b a<RESET><GREEN>y x<RESET>*=<RED>b a<RESET><GREEN>y x<RESET>/=<RED>b a<RESET><GREEN>y x<RESET>%=<RED>b a<RESET><GREEN>y x<RESET><<=<RED>b a<RESET><GREEN>y x<RESET>>>=<RED>b a<RESET><GREEN>y x<RESET>&=<RED>b a<RESET><GREEN>y x<RESET>^=<RED>b a<RESET><GREEN>y x<RESET>|=<RED>b +<RESET> +<RED>a<RESET><GREEN>y +<RESET> +<GREEN>x<RESET>,yIndex: t/t4034/typescript/post
t/t4034/typescript/post new file +16
-0@@ -0,0 +1,16 @@ +log("Hello World?") +(1) (-1e10) (0xabcdef) u'y' +!x ~x x++ x-- x*y x&y +x*y x/y x%y +x+y x-y +x<<y x>>y +x<y x<=y x>y x>=y +x==y x!=y +x&y +x^y +x|y +x&&y +x||y +x?y:z +x=y x+=y x-=y x*=y x/=y x%=y x<<=y x>>=y x&=y x^=y x|=y +x,yIndex: t/t4034/typescript/pre
t/t4034/typescript/pre new file +16
-0@@ -0,0 +1,16 @@ +log("Hello World!\n") +1 -1e10 0xabcdef 'x' +!a ~a a++ a-- a*b a&b +a*b a/b a%b +a+b a-b +a<<b a>>b +a<b a<=b a>b a>=b +a==b a!=b +a&b +a^b +a|b +a&&b +a||b +a?b:z +a=b a+=b a-=b a*=b a/=b a%=b a<<=b a>>=b a&=b a^=b a|=b +a,yIndex:
Documentation/gitattributes.txtDocumentation/gitattributes.txt +2
-0@@ -902,6 +902,8 @@ - `tex` suitable for source code for LaTeX documents. +- `typescript` suitable for source code for TypeScript language. + Customizing word diff ^^^^^^^^^^^^^^^^^^^^^
Quoted 1 line
Please be mindful that we typically wrap commit messages at 72 columns per line. Furthermore, we don't typically say "This patch", but rather use an imperative style. So instead of saying "This patch adds a biultin driver", we'd say "Add a builtin driver".
Thank you, I'll keep this in mind. Although that wasn't the intended commit message.
I tried to create a single patch out of the 4 recent commits and send it via email and this is how it came across. So, the 4 lines after that are the actual commit messages.
Quoted 6 lines
Quoted 4 lines
gitattributes: add typescript language to hunk headers support
t4034: add tests for typescriptword_regex
t4018: add tests for typescript funcname regex
userdiff: add funcname regex and wordregex for typescript languageWe don't usually provide such bulleted-list-style changes for each of the files. In this case, it shoul be fine to say something "Add tests and documentation for the new driver".
These are the original commit messages ':|. I apologize, I'm still new to using a command line mailer, so please bear with me. I'm learning how to use this well. On a side note, is there a mailer that you'd recommend?
Quoted 1 line
Last but not least, this message is missing your signoff.
I believe I made a blunder while creating a patch file since the commits are signed locally. I'll take extra care to review my mails before sending from now onwards. Thank you for your direction.
I'll submit a follow up version with patches for each commit.
A message that is not in the archive (sent off-list or not yet received): CAD6u1kiaFDcyRX7-iZBb9LtoQ1F+M18UkyJuTXsQPE0YQGafmw@mail.gmail.com
On Sat, Mar 23, 2024 at 08:18:57PM +0530, Utsav Parmar wrote:
[snip]
Quoted 7 lines
Quoted 3 lines
We don't usually provide such bulleted-list-style changes for each of the files. In this case, it shoul be fine to say something "Add tests and documentation for the new driver".
These are the original commit messages ':|. I apologize, I'm still new with using a command line mailer, so please bare with me. I'm learning how to use this well. On a side note, is there a mailer that you'd recommend?
This is of course very much a matter of taste, but I myself any many other folks use mutt or NeoMutt to access mails from the command line. Others may use for example Emacs or Alpine. If I were you I'd have a look at the alternatives that exist and then decide for yourself which one is most likely to be a good fit for you.
Patrick
PATCH 1/1 userdiff: add builtin driver for typescript language
In reply to Utsav ParmarThere are no implementation or test changes in this patch. It simply relies on the git formatting rather than the IDE git UI formatting that I believe messed up in the parent email.
--- Documentation/gitattributes.txt | 2 ++ t/t4018/typescript-arrow-function | 4 +++ t/t4018/typescript-class-member-function | 7 +++++ t/t4018/typescript-enum | 6 +++++ t/t4018/typescript-function | 4 +++ t/t4018/typescript-function-assignment | 4 +++ t/t4018/typescript-interface | 4 +++ t/t4018/typescript-type | 4 +++ t/t4034-diff-words.sh | 1 + t/t4034/typescript/expect | 33 ++++++++++++++++++++++++ t/t4034/typescript/post | 16 ++++++++++++ t/t4034/typescript/pre | 16 ++++++++++++ userdiff.c | 16 ++++++++++++ 13 files changed, 117 insertions(+) create mode 100644 t/t4018/typescript-arrow-function create mode 100644 t/t4018/typescript-class-member-function create mode 100644 t/t4018/typescript-enum create mode 100644 t/t4018/typescript-function create mode 100644 t/t4018/typescript-function-assignment create mode 100644 t/t4018/typescript-interface create mode 100644 t/t4018/typescript-type create mode 100644 t/t4034/typescript/expect create mode 100644 t/t4034/typescript/post create mode 100644 t/t4034/typescript/pre
Documentation/gitattributes.txt +2 -0
@@ -902,6 +902,8 @@ patterns are available: - `tex` suitable for source code for LaTeX documents. +- `typescript` suitable for source code for TypeScript language. + Customizing word diff ^^^^^^^^^^^^^^^^^^^^^
t/t4018/typescript-arrow-function new file +4 -0
@@ -0,0 +1,4 @@ +const RIGHT = (one) => { + someMethodCall(); + return ChangeMe; +}
t/t4018/typescript-class-member-function new file +7 -0
@@ -0,0 +1,7 @@ +class Test { + var one; + function RIGHT(two: string) { + someMethodCall(); + return ChangeMe; + } +}
t/t4018/typescript-enum new file +6 -0
@@ -0,0 +1,6 @@ +enum RIGHT { + ONE = 1, + TWO, + THREE, + ChangeMe +}
t/t4018/typescript-function new file +4 -0
@@ -0,0 +1,4 @@ +function RIGHT<Type implements AnotherType>(one: number): Type { + someMethodCall(); + return ChangeMe; +}
t/t4018/typescript-function-assignment new file +4 -0
@@ -0,0 +1,4 @@ +const RIGHT = function(one: number): Type { + someMethodCall(); + return ChangeMe; +}
t/t4018/typescript-interface new file +4 -0
@@ -0,0 +1,4 @@ +interface RIGHT { + one?: string; + [propName: ChangeMe]: any; +}
t/t4018/typescript-type new file +4 -0
@@ -0,0 +1,4 @@ +type RIGHT = { + one: number, + ChangeMe: CustomType +}
t/t4034-diff-words.sh +1 -0
@@ -338,6 +338,7 @@ test_language_driver python test_language_driver ruby test_language_driver scheme test_language_driver tex +test_language_driver typescript test_expect_success 'word-diff with diff.sbe' ' cat >pre <<-\EOF &&
t/t4034/typescript/expect new file +8 -0
@@ -0,0 +1,33 @@ +<BOLD>diff --git a/pre b/post<RESET> +<BOLD>index e4a51a2..9c56465 100644<RESET> +<BOLD>--- a/pre<RESET> +<BOLD>+++ b/post<RESET> +<CYAN>@@ -1,16 +1,16 @@<RESET> +log("Hello World<RED>!\n<RESET><GREEN>?<RESET>") +<GREEN>(<RESET>1<GREEN>) (<RESET>-1e10<GREEN>) (<RESET>0xabcdef<GREEN>) u<RESET>'<RED>x<RESET><GREEN>y<RESET>' +!<RED>a<RESET><GREEN>x<RESET> ~<RED>a a<RESET><GREEN>x x<RESET>++ <RED>a<RESET><GREEN>x<RESET>-- <RED>a<RESET><GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>&<RED>b
<RESET>
+<RED>a<RESET><GREEN>y
<RESET>
+<GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>/<RED>b a<RESET><GREEN>y x<RESET>%<RED>b
<RESET>
+<RED>a<RESET><GREEN>y
<RESET>
+<GREEN>x<RESET>+<RED>b a<RESET><GREEN>y x<RESET>-<RED>b
<RESET>
+<RED>a<RESET><GREEN>y
<RESET>
+<GREEN>x<RESET><<<RED>b a<RESET><GREEN>y x<RESET>>><RED>b
<RESET>
+<RED>a<RESET><GREEN>y
<RESET>
+<GREEN>x<RESET><<RED>b a<RESET><GREEN>y x<RESET><=<RED>b a<RESET><GREEN>y x<RESET>><RED>b a<RESET><GREEN>y x<RESET>>=<RED>b
<RESET>
+<RED>a<RESET><GREEN>y
<RESET>
+<GREEN>x<RESET>==<RED>b a<RESET><GREEN>y x<RESET>!=<RED>b
<RESET>
+<RED>a<RESET><GREEN>y
<RESET>
+<GREEN>x<RESET>&<RED>b
<RESET>
+<RED>a<RESET><GREEN>y
<RESET>
+<GREEN>x<RESET>^<RED>b
<RESET>
+<RED>a<RESET><GREEN>y
<RESET>
+<GREEN>x<RESET>|<RED>b
<RESET>
+<RED>a<RESET><GREEN>y
<RESET>
+<GREEN>x<RESET>&&<RED>b
<RESET>
+<RED>a<RESET><GREEN>y
<RESET>
+<GREEN>x<RESET>||<RED>b
<RESET>
+<RED>a<RESET><GREEN>y
<RESET>
+<GREEN>x<RESET>?<RED>b<RESET><GREEN>y<RESET>:z
+<RED>a<RESET><GREEN>x<RESET>=<RED>b a<RESET><GREEN>y x<RESET>+=<RED>b a<RESET><GREEN>y x<RESET>-=<RED>b a<RESET><GREEN>y x<RESET>*=<RED>b a<RESET><GREEN>y x<RESET>/=<RED>b a<RESET><GREEN>y x<RESET>%=<RED>b a<RESET><GREEN>y x<RESET><<=<RED>b a<RESET><GREEN>y x<RESET>>>=<RED>b a<RESET><GREEN>y x<RESET>&=<RED>b a<RESET><GREEN>y x<RESET>^=<RED>b a<RESET><GREEN>y x<RESET>|=<RED>b <RESET>
+<RED>a<RESET><GREEN>y
<RESET>
+<GREEN>x<RESET>,y
t/t4034/typescript/post new file +16 -0
@@ -0,0 +1,16 @@ +log("Hello World?") +(1) (-1e10) (0xabcdef) u'y' +!x ~x x++ x-- x*y x&y +x*y x/y x%y +x+y x-y +x<<y x>>y +x<y x<=y x>y x>=y +x==y x!=y +x&y +x^y +x|y +x&&y +x||y +x?y:z +x=y x+=y x-=y x*=y x/=y x%=y x<<=y x>>=y x&=y x^=y x|=y +x,y
t/t4034/typescript/pre new file +16 -0
@@ -0,0 +1,16 @@ +log("Hello World!\n") +1 -1e10 0xabcdef 'x' +!a ~a a++ a-- a*b a&b +a*b a/b a%b +a+b a-b +a<<b a>>b +a<b a<=b a>b a>=b +a==b a!=b +a&b +a^b +a|b +a&&b +a||b +a?b:z +a=b a+=b a-=b a*=b a/=b a%=b a<<=b a>>=b a&=b a^=b a|=b +a,y
userdiff.c +16 -0
@@ -297,6 +297,22 @@ PATTERNS("scheme", "|([^][)(}{[ \t])+"),PATTERNS ("tex" ,"^(\\\\((sub)*section|chapter|part)\\*{0,1}\\{.*)$" ,"\\\\[a-zA-Z@]+|\\\\.|([a-zA-Z0-9]|[^\x01-\x7f])+" ), +PATTERNS ("typescript" , +"^[ \t]*((enum|interface|type)[ \t]+([a-zA-Z][a-zA-Z0-9]*)+.*)$\n" +/* Method definitions */ +"^[ \t]*[a-z]+[ \t]+([A-Za-z_][A-Za-z_0-9]*)+([ \t]*=[ \t]*(function)?)?([ \t]*[A-Za-z_<>&][?&<>|.,A-Za-z_]*[ \t]*)*[ \t]*\\([^;]*$" , +/* -- */ +"[a-zA-Z_][a-zA-Z0-9_]*" +/* Integers and floats */ +"|[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?" +/* Binary */ +"|0[bB][01]+" +/* Hexadecimals */ +"|0[xX][0-9a-fA-F]+" +/* Floats starting with a decimal point */ +"|[-+]?([0-9]*\\.?[0-9]+|[0-9]+\\.?[0-9]*)([eE][-+]?[0-9]+)?" +/* Operators */ +"[-+*/%&|^!=<>]=?|===|!==|<<=?|>>=?|&&|\\|\\||\\?\\?|\\+\\+|--|~" ), { "default", NULL, NULL, -1, { NULL, 0 } }, };#undef PATTERNS
Signature · 1 line
2.34.1
Re: [PATCH] userdiff: add builtin driver for typescript language
Quoted 1 line · Utsav Parmar
There are no implementation or test changes in this patch. It simply relies on the git formatting rather than the IDE git UI formatting that I believe messed up in the parent email.
Commit messages are supposed to be at most 72 characters wide, so please reflow the commit message to match that limit. Furthermore, when you send an updated patch, please make sure to increment the patch version so that folks have an easier time to follow the evolution of your patch. This can be done by passing e.g. -v2 to git-format-patch(1) or git-send-email(1).
Other than that I don't have a lot to say about this patch and will hope for somebody else to review the TypeScript-related things.
Thanks!
Patrick
Quoted 267 lines
Signed-off-by Utsav Parmar <[email protected]>--- Documentation/gitattributes.txt | 2 ++ t/t4018/typescript-arrow-function | 4 +++ t/t4018/typescript-class-member-function | 7 +++++ t/t4018/typescript-enum | 6 +++++ t/t4018/typescript-function | 4 +++ t/t4018/typescript-function-assignment | 4 +++ t/t4018/typescript-interface | 4 +++ t/t4018/typescript-type | 4 +++ t/t4034-diff-words.sh | 1 + t/t4034/typescript/expect | 33 ++++++++++++++++++++++++ t/t4034/typescript/post | 16 ++++++++++++ t/t4034/typescript/pre | 16 ++++++++++++ userdiff.c | 16 ++++++++++++ 13 files changed, 117 insertions(+) create mode 100644 t/t4018/typescript-arrow-function create mode 100644 t/t4018/typescript-class-member-function create mode 100644 t/t4018/typescript-enum create mode 100644 t/t4018/typescript-function create mode 100644 t/t4018/typescript-function-assignment create mode 100644 t/t4018/typescript-interface create mode 100644 t/t4018/typescript-type create mode 100644 t/t4034/typescript/expect create mode 100644 t/t4034/typescript/post create mode 100644 t/t4034/typescript/preDocumentation/gitattributes.txt +2
-0@@ -902,6 +902,8 @@ patterns are available: - `tex` suitable for source code for LaTeX documents. +- `typescript` suitable for source code for TypeScript language. + Customizing word diff ^^^^^^^^^^^^^^^^^^^^^t/t4018/typescript-arrow-function new file +4
-0@@ -0,0 +1,4 @@ +const RIGHT = (one) => { + someMethodCall(); + return ChangeMe; +}t/t4018/typescript-class-member-function new file +7
-0@@ -0,0 +1,7 @@ +class Test { + var one; + function RIGHT(two: string) { + someMethodCall(); + return ChangeMe; + } +}t/t4018/typescript-enum new file +6
-0@@ -0,0 +1,6 @@ +enum RIGHT { + ONE = 1, + TWO, + THREE, + ChangeMe +}t/t4018/typescript-function new file +4
-0@@ -0,0 +1,4 @@ +function RIGHT<Type implements AnotherType>(one: number): Type { + someMethodCall(); + return ChangeMe; +}t/t4018/typescript-function-assignment new file +4
-0@@ -0,0 +1,4 @@ +const RIGHT = function(one: number): Type { + someMethodCall(); + return ChangeMe; +}t/t4018/typescript-interface new file +4
-0@@ -0,0 +1,4 @@ +interface RIGHT { + one?: string; + [propName: ChangeMe]: any; +}t/t4018/typescript-type new file +4
-0@@ -0,0 +1,4 @@ +type RIGHT = { + one: number, + ChangeMe: CustomType +}t/t4034-diff-words.sh +1
-0@@ -338,6 +338,7 @@ test_language_driver python test_language_driver ruby test_language_driver scheme test_language_driver tex +test_language_driver typescript test_expect_success 'word-diff with diff.sbe' ' cat >pre <<-\EOF &&t/t4034/typescript/expect new file +8
-0@@ -0,0 +1,33 @@ +<BOLD>diff --git a/pre b/post<RESET> +<BOLD>index e4a51a2..9c56465 100644<RESET> +<BOLD>--- a/pre<RESET> +<BOLD>+++ b/post<RESET> +<CYAN>@@ -1,16 +1,16 @@<RESET> +log("Hello World<RED>!\n<RESET><GREEN>?<RESET>") +<GREEN>(<RESET>1<GREEN>) (<RESET>-1e10<GREEN>) (<RESET>0xabcdef<GREEN>) u<RESET>'<RED>x<RESET><GREEN>y<RESET>' +!<RED>a<RESET><GREEN>x<RESET> ~<RED>a a<RESET><GREEN>x x<RESET>++ <RED>a<RESET><GREEN>x<RESET>-- <RED>a<RESET><GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>&<RED>b<RESET>
+<RED>a<RESET><GREEN>y
<RESET>
+<GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>/<RED>b a<RESET><GREEN>y x<RESET>%<RED>b
<RESET>
+<RED>a<RESET><GREEN>y
<RESET>
+<GREEN>x<RESET>+<RED>b a<RESET><GREEN>y x<RESET>-<RED>b
<RESET>
+<RED>a<RESET><GREEN>y
<RESET>
+<GREEN>x<RESET><<<RED>b a<RESET><GREEN>y x<RESET>>><RED>b
<RESET>
+<RED>a<RESET><GREEN>y
<RESET>
+<GREEN>x<RESET><<RED>b a<RESET><GREEN>y x<RESET><=<RED>b a<RESET><GREEN>y x<RESET>><RED>b a<RESET><GREEN>y x<RESET>>=<RED>b
<RESET>
+<RED>a<RESET><GREEN>y
<RESET>
+<GREEN>x<RESET>==<RED>b a<RESET><GREEN>y x<RESET>!=<RED>b
<RESET>
+<RED>a<RESET><GREEN>y
<RESET>
+<GREEN>x<RESET>&<RED>b
<RESET>
+<RED>a<RESET><GREEN>y
<RESET>
+<GREEN>x<RESET>^<RED>b
<RESET>
+<RED>a<RESET><GREEN>y
<RESET>
+<GREEN>x<RESET>|<RED>b
<RESET>
+<RED>a<RESET><GREEN>y
<RESET>
+<GREEN>x<RESET>&&<RED>b
<RESET>
+<RED>a<RESET><GREEN>y
<RESET>
+<GREEN>x<RESET>||<RED>b
<RESET>
+<RED>a<RESET><GREEN>y
<RESET>
+<GREEN>x<RESET>?<RED>b<RESET><GREEN>y<RESET>:z
+<RED>a<RESET><GREEN>x<RESET>=<RED>b a<RESET><GREEN>y x<RESET>+=<RED>b a<RESET><GREEN>y x<RESET>-=<RED>b a<RESET><GREEN>y x<RESET>*=<RED>b a<RESET><GREEN>y x<RESET>/=<RED>b a<RESET><GREEN>y x<RESET>%=<RED>b a<RESET><GREEN>y x<RESET><<=<RED>b a<RESET><GREEN>y x<RESET>>>=<RED>b a<RESET><GREEN>y x<RESET>&=<RED>b a<RESET><GREEN>y x<RESET>^=<RED>b a<RESET><GREEN>y x<RESET>|=<RED>b <RESET>
+<RED>a<RESET><GREEN>y
<RESET>
+<GREEN>x<RESET>,yt/t4034/typescript/post new file +16
-0@@ -0,0 +1,16 @@ +log("Hello World?") +(1) (-1e10) (0xabcdef) u'y' +!x ~x x++ x-- x*y x&y +x*y x/y x%y +x+y x-y +x<<y x>>y +x<y x<=y x>y x>=y +x==y x!=y +x&y +x^y +x|y +x&&y +x||y +x?y:z +x=y x+=y x-=y x*=y x/=y x%=y x<<=y x>>=y x&=y x^=y x|=y +x,yt/t4034/typescript/pre new file +16
-0@@ -0,0 +1,16 @@ +log("Hello World!\n") +1 -1e10 0xabcdef 'x' +!a ~a a++ a-- a*b a&b +a*b a/b a%b +a+b a-b +a<<b a>>b +a<b a<=b a>b a>=b +a==b a!=b +a&b +a^b +a|b +a&&b +a||b +a?b:z +a=b a+=b a-=b a*=b a/=b a%=b a<<=b a>>=b a&=b a^=b a|=b +a,yuserdiff.c +16
-0@@ -297,6 +297,22 @@ PATTERNS("scheme", "|([^][)(}{[ \t])+"),PATTERNS ("tex" ,"^(\\\\((sub)*section|chapter|part)\\*{0,1}\\{.*)$" ,"\\\\[a-zA-Z@]+|\\\\.|([a-zA-Z0-9]|[^\x01-\x7f])+" ), +PATTERNS ("typescript" , +"^[ \t]*((enum|interface|type)[ \t]+([a-zA-Z][a-zA-Z0-9]*)+.*)$\n" +/* Method definitions */ +"^[ \t]*[a-z]+[ \t]+([A-Za-z_][A-Za-z_0-9]*)+([ \t]*=[ \t]*(function)?)?([ \t]*[A-Za-z_<>&][?&<>|.,A-Za-z_]*[ \t]*)*[ \t]*\\([^;]*$" , +/* -- */ +"[a-zA-Z_][a-zA-Z0-9_]*" +/* Integers and floats */ +"|[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?" +/* Binary */ +"|0[bB][01]+" +/* Hexadecimals */ +"|0[xX][0-9a-fA-F]+" +/* Floats starting with a decimal point */ +"|[-+]?([0-9]*\\.?[0-9]+|[0-9]+\\.?[0-9]*)([eE][-+]?[0-9]+)?" +/* Operators */ +"[-+*/%&|^!=<>]=?|===|!==|<<=?|>>=?|&&|\\|\\||\\?\\?|\\+\\+|--|~" ), { "default", NULL, NULL, -1, { NULL, 0 } }, };#undef PATTERNSSignature · 1 line
2.34.1
Re: [PATCH] userdiff: add builtin driver for typescript language
In reply to Utsav ParmarUtsav Parmar <[email protected]> writes:
Hello,
Quoted 2 lines
There are no implementation or test changes in this patch. It simply relies on the git formatting rather than the IDE git UI formatting that I believe messed up in the parent email.
I think Patrick mentioned this already, but seems like the new patch too needs to be wrapped to 72 chars. Also when we send a follow up patch, we version it accordingly like "[PATCH v2]". I would suggest reading 'Documentation/MyFirstContribution.txt'.
PATCH v2 1/1 userdiff: add builtin driver for typescript language
In reply to Utsav Parmar--- Documentation/gitattributes.txt | 2 ++ t/t4018/typescript-arrow-function | 4 +++ t/t4018/typescript-class-member-function | 7 +++++ t/t4018/typescript-enum | 6 +++++ t/t4018/typescript-function | 4 +++ t/t4018/typescript-function-assignment | 4 +++ t/t4018/typescript-interface | 4 +++ t/t4018/typescript-type | 4 +++ t/t4034-diff-words.sh | 1 + t/t4034/typescript/expect | 33 ++++++++++++++++++++++++ t/t4034/typescript/post | 16 ++++++++++++ t/t4034/typescript/pre | 16 ++++++++++++ userdiff.c | 16 ++++++++++++ 13 files changed, 117 insertions(+) create mode 100644 t/t4018/typescript-arrow-function create mode 100644 t/t4018/typescript-class-member-function create mode 100644 t/t4018/typescript-enum create mode 100644 t/t4018/typescript-function create mode 100644 t/t4018/typescript-function-assignment create mode 100644 t/t4018/typescript-interface create mode 100644 t/t4018/typescript-type create mode 100644 t/t4034/typescript/expect create mode 100644 t/t4034/typescript/post create mode 100644 t/t4034/typescript/pre
Documentation/gitattributes.txt +2 -0
@@ -902,6 +902,8 @@ patterns are available: - `tex` suitable for source code for LaTeX documents. +- `typescript` suitable for source code for TypeScript language. + Customizing word diff ^^^^^^^^^^^^^^^^^^^^^
t/t4018/typescript-arrow-function new file +4 -0
@@ -0,0 +1,4 @@ +const RIGHT = (one) => { + someMethodCall(); + return ChangeMe; +}
t/t4018/typescript-class-member-function new file +7 -0
@@ -0,0 +1,7 @@ +class Test { + var one; + function RIGHT(two: string) { + someMethodCall(); + return ChangeMe; + } +}
t/t4018/typescript-enum new file +6 -0
@@ -0,0 +1,6 @@ +enum RIGHT { + ONE = 1, + TWO, + THREE, + ChangeMe +}
t/t4018/typescript-function new file +4 -0
@@ -0,0 +1,4 @@ +function RIGHT<Type implements AnotherType>(one: number): Type { + someMethodCall(); + return ChangeMe; +}
t/t4018/typescript-function-assignment new file +4 -0
@@ -0,0 +1,4 @@ +const RIGHT = function(one: number): Type { + someMethodCall(); + return ChangeMe; +}
t/t4018/typescript-interface new file +4 -0
@@ -0,0 +1,4 @@ +interface RIGHT { + one?: string; + [propName: ChangeMe]: any; +}
t/t4018/typescript-type new file +4 -0
@@ -0,0 +1,4 @@ +type RIGHT = { + one: number, + ChangeMe: CustomType +}
t/t4034-diff-words.sh +1 -0
@@ -338,6 +338,7 @@ test_language_driver python test_language_driver ruby test_language_driver scheme test_language_driver tex +test_language_driver typescript test_expect_success 'word-diff with diff.sbe' ' cat >pre <<-\EOF &&
t/t4034/typescript/expect new file +8 -0
@@ -0,0 +1,33 @@ +<BOLD>diff --git a/pre b/post<RESET> +<BOLD>index e4a51a2..9c56465 100644<RESET> +<BOLD>--- a/pre<RESET> +<BOLD>+++ b/post<RESET> +<CYAN>@@ -1,16 +1,16 @@<RESET> +log("Hello World<RED>!\n<RESET><GREEN>?<RESET>") +<GREEN>(<RESET>1<GREEN>) (<RESET>-1e10<GREEN>) (<RESET>0xabcdef<GREEN>) u<RESET>'<RED>x<RESET><GREEN>y<RESET>' +!<RED>a<RESET><GREEN>x<RESET> ~<RED>a a<RESET><GREEN>x x<RESET>++ <RED>a<RESET><GREEN>x<RESET>-- <RED>a<RESET><GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>&<RED>b
<RESET>
+<RED>a<RESET><GREEN>y
<RESET>
+<GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>/<RED>b a<RESET><GREEN>y x<RESET>%<RED>b
<RESET>
+<RED>a<RESET><GREEN>y
<RESET>
+<GREEN>x<RESET>+<RED>b a<RESET><GREEN>y x<RESET>-<RED>b
<RESET>
+<RED>a<RESET><GREEN>y
<RESET>
+<GREEN>x<RESET><<<RED>b a<RESET><GREEN>y x<RESET>>><RED>b
<RESET>
+<RED>a<RESET><GREEN>y
<RESET>
+<GREEN>x<RESET><<RED>b a<RESET><GREEN>y x<RESET><=<RED>b a<RESET><GREEN>y x<RESET>><RED>b a<RESET><GREEN>y x<RESET>>=<RED>b
<RESET>
+<RED>a<RESET><GREEN>y
<RESET>
+<GREEN>x<RESET>==<RED>b a<RESET><GREEN>y x<RESET>!=<RED>b
<RESET>
+<RED>a<RESET><GREEN>y
<RESET>
+<GREEN>x<RESET>&<RED>b
<RESET>
+<RED>a<RESET><GREEN>y
<RESET>
+<GREEN>x<RESET>^<RED>b
<RESET>
+<RED>a<RESET><GREEN>y
<RESET>
+<GREEN>x<RESET>|<RED>b
<RESET>
+<RED>a<RESET><GREEN>y
<RESET>
+<GREEN>x<RESET>&&<RED>b
<RESET>
+<RED>a<RESET><GREEN>y
<RESET>
+<GREEN>x<RESET>||<RED>b
<RESET>
+<RED>a<RESET><GREEN>y
<RESET>
+<GREEN>x<RESET>?<RED>b<RESET><GREEN>y<RESET>:z
+<RED>a<RESET><GREEN>x<RESET>=<RED>b a<RESET><GREEN>y x<RESET>+=<RED>b a<RESET><GREEN>y x<RESET>-=<RED>b a<RESET><GREEN>y x<RESET>*=<RED>b a<RESET><GREEN>y x<RESET>/=<RED>b a<RESET><GREEN>y x<RESET>%=<RED>b a<RESET><GREEN>y x<RESET><<=<RED>b a<RESET><GREEN>y x<RESET>>>=<RED>b a<RESET><GREEN>y x<RESET>&=<RED>b a<RESET><GREEN>y x<RESET>^=<RED>b a<RESET><GREEN>y x<RESET>|=<RED>b <RESET>
+<RED>a<RESET><GREEN>y
<RESET>
+<GREEN>x<RESET>,y
t/t4034/typescript/post new file +16 -0
@@ -0,0 +1,16 @@ +log("Hello World?") +(1) (-1e10) (0xabcdef) u'y' +!x ~x x++ x-- x*y x&y +x*y x/y x%y +x+y x-y +x<<y x>>y +x<y x<=y x>y x>=y +x==y x!=y +x&y +x^y +x|y +x&&y +x||y +x?y:z +x=y x+=y x-=y x*=y x/=y x%=y x<<=y x>>=y x&=y x^=y x|=y +x,y
t/t4034/typescript/pre new file +16 -0
@@ -0,0 +1,16 @@ +log("Hello World!\n") +1 -1e10 0xabcdef 'x' +!a ~a a++ a-- a*b a&b +a*b a/b a%b +a+b a-b +a<<b a>>b +a<b a<=b a>b a>=b +a==b a!=b +a&b +a^b +a|b +a&&b +a||b +a?b:z +a=b a+=b a-=b a*=b a/=b a%=b a<<=b a>>=b a&=b a^=b a|=b +a,y
userdiff.c +16 -0
@@ -297,6 +297,22 @@ PATTERNS("scheme", "|([^][)(}{[ \t])+"),PATTERNS ("tex" ,"^(\\\\((sub)*section|chapter|part)\\*{0,1}\\{.*)$" ,"\\\\[a-zA-Z@]+|\\\\.|([a-zA-Z0-9]|[^\x01-\x7f])+" ), +PATTERNS ("typescript" , +"^[ \t]*((enum|interface|type)[ \t]+([a-zA-Z][a-zA-Z0-9]*)+.*)$\n" +/* Method definitions */ +"^[ \t]*[a-z]+[ \t]+([A-Za-z_][A-Za-z_0-9]*)+([ \t]*=[ \t]*(function)?)?([ \t]*[A-Za-z_<>&][?&<>|.,A-Za-z_]*[ \t]*)*[ \t]*\\([^;]*$" , +/* -- */ +"[a-zA-Z_][a-zA-Z0-9_]*" +/* Integers and floats */ +"|[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?" +/* Binary */ +"|0[bB][01]+" +/* Hexadecimals */ +"|0[xX][0-9a-fA-F]+" +/* Floats starting with a decimal point */ +"|[-+]?([0-9]*\\.?[0-9]+|[0-9]+\\.?[0-9]*)([eE][-+]?[0-9]+)?" +/* Operators */ +"[-+*/%&|^!=<>]=?|===|!==|<<=?|>>=?|&&|\\|\\||\\?\\?|\\+\\+|--|~" ), { "default", NULL, NULL, -1, { NULL, 0 } }, };#undef PATTERNS
Signature · 1 line
2.34.1
Re: [PATCH v2] userdiff: add builtin driver for typescript language
Quoted 1 line · Utsav Parmar
Subject: Re: [PATCH v2] userdiff: add builtin driver for typescript language
"builtin driver" -> "patterns", probably, as the "userdiff" customization does not allow adding any new code.
Documentation/gitattributes.txt patterns are available: · line 906
Quoted 10 lines
Documentation/gitattributes.txt +2
-0@@ -902,6 +902,8 @@ patterns are available: - `tex` suitable for source code for LaTeX documents. +- `typescript` suitable for source code for TypeScript language. +
Good that you did not forget to add an entry to this list (and to the right place).
Quoted 16 lines
t/t4018/typescript-function-assignment new file +4
-0@@ -0,0 +1,4 @@ +const RIGHT = function(one: number): Type { + someMethodCall(); + return ChangeMe; +}t/t4018/typescript-interface new file +0
-0
t/t4018/typescript-interface line 4
Quoted 5 lines
t/t4018/typescript-interface new file +4
-0@@ -0,0 +1,4 @@ +interface RIGHT { + one?: string; + [propName: ChangeMe]: any; +}
I do not speak typescript, but is it important for the language that the sources can be stored with an incomplete line at the end of the file? IOW, I am wondering if it is deliberate *and* matters to the tests that some sample files end with an incomplete line while others do not.
If that is not the case, please fix this and the next file; we do not generally want a file with an incomplete line at the end unless there is a compelling reason to (i.e., we do test that our tools work with such files, and it may be convenient to ship sample input with incomplete lines to run such tests).
As to the actual pattern and the words the patterns catch, I have no idea if they are sensible for typescript language---folks with more experience than myself should lend their eyeballs to review.
Thanks.
Re: [PATCH v2] userdiff: add builtin driver for typescript language
In reply to Utsav ParmarQuoted 15 lines · Utsav Parmar
...
t/t4034/typescript/expect new file +8
-0@@ -0,0 +1,33 @@ +<BOLD>diff --git a/pre b/post<RESET> +<BOLD>index e4a51a2..9c56465 100644<RESET> +<BOLD>--- a/pre<RESET> +<BOLD>+++ b/post<RESET> +<CYAN>@@ -1,16 +1,16 @@<RESET> +log("Hello World<RED>!\n<RESET><GREEN>?<RESET>") +<GREEN>(<RESET>1<GREEN>) (<RESET>-1e10<GREEN>) (<RESET>0xabcdef<GREEN>) u<RESET>'<RED>x<RESET><GREEN>y<RESET>' +!<RED>a<RESET><GREEN>x<RESET> ~<RED>a a<RESET><GREEN>x x<RESET>++ <RED>a<RESET><GREEN>x<RESET>-- <RED>a<RESET><GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>&<RED>b
Quoted 1 line
<RESET>
There is a funny line-wrapping around here that corrupts the patch.
Quoted 2 lines
+<RED>a<RESET><GREEN>y
<RESET>