Skip to content

[GSoC] userdiff: adding typescript pattern#2251

Open
Dhruv-0-Arora wants to merge 2 commits intogit:masterfrom
Dhruv-0-Arora:userdiff/typescript-pattern
Open

[GSoC] userdiff: adding typescript pattern#2251
Dhruv-0-Arora wants to merge 2 commits intogit:masterfrom
Dhruv-0-Arora:userdiff/typescript-pattern

Conversation

@Dhruv-0-Arora
Copy link
Copy Markdown

@Dhruv-0-Arora Dhruv-0-Arora commented Mar 22, 2026

Description

  • Add builtin userdiff pattern for TypeScript files. Recognizes function declarations, class definitions, arrow functions, and method definitions.

    • Handles common modifiers like export, async, static, etc
  • Added tests for the typescript pattern in userdiff.

cc: Johannes Sixt j6t@kdbg.org
cc: Ben Knoble ben.knoble@gmail.com

@gitgitgadget-git
Copy link
Copy Markdown

Welcome to GitGitGadget

Hi @Dhruv-0-Arora, and welcome to GitGitGadget, the GitHub App to send patch series to the Git mailing list from GitHub Pull Requests.

Please make sure that either:

  • Your Pull Request has a good description, if it consists of multiple commits, as it will be used as cover letter.
  • Your Pull Request description is empty, if it consists of a single commit, as the commit message should be descriptive enough by itself.

You can CC potential reviewers by adding a footer to the PR description with the following syntax:

CC: Revi Ewer <revi.ewer@example.com>, Ill Takalook <ill.takalook@example.net>

NOTE: DO NOT copy/paste your CC list from a previous GGG PR's description,
because it will result in a malformed CC list on the mailing list. See
example.

Also, it is a good idea to review the commit messages one last time, as the Git project expects them in a quite specific form:

  • the lines should not exceed 76 columns,
  • the first line should be like a header and typically start with a prefix like "tests:" or "revisions:" to state which subsystem the change is about, and
  • the commit messages' body should be describing the "why?" of the change.
  • Finally, the commit messages should end in a Signed-off-by: line matching the commits' author.

It is in general a good idea to await the automated test ("Checks") in this Pull Request before contributing the patches, e.g. to avoid trivial issues such as unportable code.

Contributing the patches

Before you can contribute the patches, your GitHub username needs to be added to the list of permitted users. Any already-permitted user can do that, by adding a comment to your PR of the form /allow. A good way to find other contributors is to locate recent pull requests where someone has been /allowed:

Both the person who commented /allow and the PR author are able to /allow you.

An alternative is the channel #git-devel on the Libera Chat IRC network:

<newcontributor> I've just created my first PR, could someone please /allow me? https://github.com/gitgitgadget/git/pull/12345
<veteran> newcontributor: it is done
<newcontributor> thanks!

Once on the list of permitted usernames, you can contribute the patches to the Git mailing list by adding a PR comment /submit.

If you want to see what email(s) would be sent for a /submit request, add a PR comment /preview to have the email(s) sent to you. You must have a public GitHub email address for this. Note that any reviewers CC'd via the list in the PR description will not actually be sent emails.

After you submit, GitGitGadget will respond with another comment that contains the link to the cover letter mail in the Git mailing list archive. Please make sure to monitor the discussion in that thread and to address comments and suggestions (while the comments and suggestions will be mirrored into the PR by GitGitGadget, you will still want to reply via mail).

If you do not want to subscribe to the Git mailing list just to be able to respond to a mail, you can download the mbox from the Git mailing list archive (click the (raw) link), then import it into your mail program. If you use GMail, you can do this via:

curl -g --user "<EMailAddress>:<Password>" \
    --url "imaps://imap.gmail.com/INBOX" -T /path/to/raw.txt

To iterate on your change, i.e. send a revised patch or patch series, you will first want to (force-)push to the same branch. You probably also want to modify your Pull Request description (or title). It is a good idea to summarize the revision by adding something like this to the cover letter (read: by editing the first comment on the PR, i.e. the PR description):

Changes since v1:
- Fixed a typo in the commit message (found by ...)
- Added a code comment to ... as suggested by ...
...

To send a new iteration, just add another PR comment with the contents: /submit.

Need help?

New contributors who want advice are encouraged to join git-mentoring@googlegroups.com, where volunteers who regularly contribute to Git are willing to answer newbie questions, give advice, or otherwise provide mentoring to interested contributors. You must join in order to post or view messages, but anyone can join.

You may also be able to find help in real time in the developer IRC channel, #git-devel on Libera Chat. Remember that IRC does not support offline messaging, so if you send someone a private message and log out, they cannot respond to you. The scrollback of #git-devel is archived, though.

@Dhruv-0-Arora Dhruv-0-Arora force-pushed the userdiff/typescript-pattern branch from 55f9b3c to b12d2d7 Compare March 22, 2026 19:46
@gitgitgadget-git
Copy link
Copy Markdown

There is a merge commit in this Pull Request:

70961541ade01089aad45f7b04d43fcbf6ebc34a

Please rebase the branch and force-push.

Add builtin userdiff pattern for TypeScript files.
Recognizes function declarations, class definitions,
arrow functions, and method definitions.

Handles common modifiers like export, async, static, etc..

Signed-off-by: Dhruv Arora <a_dhruv@outlook.com>
- Typescript pattern was not in alphabetical order, causing failing tests.
- Added 3 new typescript tests.
- Fixed pattern bug - incorrectly identifying const|let|var instead of
function or class.

Signed-off-by: Dhruv Arora <a_dhruv@outlook.com>
@Dhruv-0-Arora Dhruv-0-Arora force-pushed the userdiff/typescript-pattern branch from a258730 to d684d93 Compare March 25, 2026 12:55
@Dhruv-0-Arora Dhruv-0-Arora changed the title userdiff: adding typescript pattern [GSoC] userdiff: adding typescript pattern Mar 25, 2026
@Dhruv-0-Arora
Copy link
Copy Markdown
Author

@dscho could you /allow me?

@dscho
Copy link
Copy Markdown
Member

dscho commented Mar 28, 2026

/allow

@gitgitgadget-git
Copy link
Copy Markdown

User Dhruv-0-Arora is now allowed to use GitGitGadget.

@Dhruv-0-Arora
Copy link
Copy Markdown
Author

/allow

Thank you!

@Dhruv-0-Arora
Copy link
Copy Markdown
Author

/submit

@gitgitgadget-git
Copy link
Copy Markdown

Error: Ignoring PR with empty title and/or body

@Dhruv-0-Arora
Copy link
Copy Markdown
Author

/submit

@gitgitgadget-git
Copy link
Copy Markdown

Submitted as pull.2251.git.git.1774734004.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-git-2251/Dhruv-0-Arora/userdiff/typescript-pattern-v1

To fetch this version to local tag pr-git-2251/Dhruv-0-Arora/userdiff/typescript-pattern-v1:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-git-2251/Dhruv-0-Arora/userdiff/typescript-pattern-v1

@gitgitgadget-git
Copy link
Copy Markdown

Junio C Hamano wrote on the Git mailing list (how to reply to this email):

"Dhruv Arora via GitGitGadget" <gitgitgadget@gmail.com> writes:

> Description
> ===========
>
>  * Add builtin userdiff pattern for TypeScript files. Recognizes function
>    declarations, class definitions, arrow functions, and method definitions.
>    
>    * Handles common modifiers like export, async, static, etc
>
>  * Added tests for the typescript pattern in userdiff.
>
> Dhruv Arora (2):
>   userdiff: adding typescript pattern
>   fix(userdiff): sorted pattern and tests

We frown upon a patch series that makes mistakes in an earlier step,
only to fix them in a later step.  The "git rebase -i" command helps
us pretend to be more perfect developers than we actually are,
whipping your patch series into a shape that builds one small step
on top of another in a logical succession.  Such a patch series is
easier to understand than a history that faithfully records all the
stumbles the developer made until they reached the final solution.

Just have a single patch that adds the right pattern at the right
place and add necessary tests.

When/if your reviewers suggest further changes, the way you should
work on them is the same.  Pretend as if you discarded everything
you did, started from scratch, and reached the ideal result without
making any mistakes or taking any detours along the way.

Thanks.

>  t/t4018/typescript-class-method         |  7 +++++++
>  t/t4018/typescript-export-default-class |  7 +++++++
>  t/t4018/typescript-export-function      |  7 +++++++
>  userdiff.c                              | 15 +++++++++++++++
>  4 files changed, 36 insertions(+)
>  create mode 100644 t/t4018/typescript-class-method
>  create mode 100644 t/t4018/typescript-export-default-class
>  create mode 100644 t/t4018/typescript-export-function
>
>
> base-commit: ce74208c2fa13943fffa58f168ac27a76d0eb789
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2251%2FDhruv-0-Arora%2Fuserdiff%2Ftypescript-pattern-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2251/Dhruv-0-Arora/userdiff/typescript-pattern-v1
> Pull-Request: https://github.com/git/git/pull/2251

@gitgitgadget-git
Copy link
Copy Markdown

Johannes Sixt wrote on the Git mailing list (how to reply to this email):

Am 28.03.26 um 22:40 schrieb Dhruv Arora via GitGitGadget:
> 
> Description
> ===========
> 
>  * Add builtin userdiff pattern for TypeScript files. Recognizes function
>    declarations, class definitions, arrow functions, and method definitions.
>    
>    * Handles common modifiers like export, async, static, etc
> 
>  * Added tests for the typescript pattern in userdiff.
> 
> Dhruv Arora (2):
>   userdiff: adding typescript pattern
>   fix(userdiff): sorted pattern and tests
> 
>  t/t4018/typescript-class-method         |  7 +++++++
>  t/t4018/typescript-export-default-class |  7 +++++++
>  t/t4018/typescript-export-function      |  7 +++++++
>  userdiff.c                              | 15 +++++++++++++++
>  4 files changed, 36 insertions(+)
>  create mode 100644 t/t4018/typescript-class-method
>  create mode 100644 t/t4018/typescript-export-default-class
>  create mode 100644 t/t4018/typescript-export-function
> 
> 
> base-commit: ce74208c2fa13943fffa58f168ac27a76d0eb789
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2251%2FDhruv-0-Arora%2Fuserdiff%2Ftypescript-pattern-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2251/Dhruv-0-Arora/userdiff/typescript-pattern-v1
> Pull-Request: https://github.com/git/git/pull/2251

Javascript and Typescript are related languages, if I am not mistaken.
It would be appreciated if the new language driver could be used for
both. Then the driver's name should be the superset language and the
documentation (missing, BTW) should mention that the driver can be used
for both languages.

We have had a number of submissions for Javascript or Typescript drivers
in the past, but none of them were followed through to be integrated.

Typescript:

https://lore.kernel.org/git/20240404163827.5855-1-utsavp0213@gmail.com/
https://lore.kernel.org/git/pull.1746.git.git.1721061218993.gitgitgadget@gmail.com/

Javascript:

https://lore.kernel.org/git/20240301074048.188835-1-sergiusnyah@gmail.com/
https://lore.kernel.org/git/20220403132508.28196-1-a97410985new@gmail.com/
https://lore.kernel.org/git/20250604094100.80598-1-derick.william.moraes@gmail.com/

Please review these submission and the responses that they received.
Perhaps you can find inspiration for improvement from them.

-- Hannes

@gitgitgadget-git
Copy link
Copy Markdown

User Johannes Sixt <j6t@kdbg.org> has been added to the cc: list.

@gitgitgadget-git
Copy link
Copy Markdown

Ben Knoble wrote on the Git mailing list (how to reply to this email):

> Le 29 mars 2026 à 05:32, Johannes Sixt <j6t@kdbg.org> a écrit :
> 
> Javascript and Typescript are related languages, if I am not mistaken.
> 
> -- Hannes

FWIW, I believe both languages are officially spelled with a capital S: “JavaScript”, “TypeScript”. At least that is how Wikipedia and official sites present them.

I knew what you meant of course, and will now take my pedant hat off ;)

@gitgitgadget-git
Copy link
Copy Markdown

User Ben Knoble <ben.knoble@gmail.com> has been added to the cc: list.

@gitgitgadget-git
Copy link
Copy Markdown

Junio C Hamano wrote on the Git mailing list (how to reply to this email):

"Dhruv Arora via GitGitGadget" <gitgitgadget@gmail.com> writes:

> Description
> ===========
>
>  * Add builtin userdiff pattern for TypeScript files. Recognizes function
>    declarations, class definitions, arrow functions, and method definitions.
>    
>    * Handles common modifiers like export, async, static, etc
>
>  * Added tests for the typescript pattern in userdiff.
>
> Dhruv Arora (2):
>   userdiff: adding typescript pattern
>   fix(userdiff): sorted pattern and tests

We frown upon a patch series that makes mistakes in an earlier step,
only to fix them in a later step.  The "git rebase -i" command helps
us pretend to be more perfect developers than we actually are,
whipping your patch series into a shape that builds one small step
on top of another in a logical succession.  Such a patch series is
easier to understand than a history that faithfully records all the
stumbles the developer made until they reached the final solution.

Just have a single patch that adds the right pattern at the right
place and add necessary tests.

When/if your reviewers suggest further changes, the way you should
work on them is the same.  Pretend as if you discarded everything
you did, started from scratch, and reached the ideal result without
making any mistakes or taking any detours along the way.

Thanks.

>  t/t4018/typescript-class-method         |  7 +++++++
>  t/t4018/typescript-export-default-class |  7 +++++++
>  t/t4018/typescript-export-function      |  7 +++++++
>  userdiff.c                              | 15 +++++++++++++++
>  4 files changed, 36 insertions(+)
>  create mode 100644 t/t4018/typescript-class-method
>  create mode 100644 t/t4018/typescript-export-default-class
>  create mode 100644 t/t4018/typescript-export-function
>
>
> base-commit: ce74208c2fa13943fffa58f168ac27a76d0eb789
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2251%2FDhruv-0-Arora%2Fuserdiff%2Ftypescript-pattern-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2251/Dhruv-0-Arora/userdiff/typescript-pattern-v1
> Pull-Request: https://github.com/git/git/pull/2251

@gitgitgadget-git
Copy link
Copy Markdown

Johannes Sixt wrote on the Git mailing list (how to reply to this email):

Am 28.03.26 um 22:40 schrieb Dhruv Arora via GitGitGadget:
> 
> Description
> ===========
> 
>  * Add builtin userdiff pattern for TypeScript files. Recognizes function
>    declarations, class definitions, arrow functions, and method definitions.
>    
>    * Handles common modifiers like export, async, static, etc
> 
>  * Added tests for the typescript pattern in userdiff.
> 
> Dhruv Arora (2):
>   userdiff: adding typescript pattern
>   fix(userdiff): sorted pattern and tests
> 
>  t/t4018/typescript-class-method         |  7 +++++++
>  t/t4018/typescript-export-default-class |  7 +++++++
>  t/t4018/typescript-export-function      |  7 +++++++
>  userdiff.c                              | 15 +++++++++++++++
>  4 files changed, 36 insertions(+)
>  create mode 100644 t/t4018/typescript-class-method
>  create mode 100644 t/t4018/typescript-export-default-class
>  create mode 100644 t/t4018/typescript-export-function
> 
> 
> base-commit: ce74208c2fa13943fffa58f168ac27a76d0eb789
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2251%2FDhruv-0-Arora%2Fuserdiff%2Ftypescript-pattern-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2251/Dhruv-0-Arora/userdiff/typescript-pattern-v1
> Pull-Request: https://github.com/git/git/pull/2251

Javascript and Typescript are related languages, if I am not mistaken.
It would be appreciated if the new language driver could be used for
both. Then the driver's name should be the superset language and the
documentation (missing, BTW) should mention that the driver can be used
for both languages.

We have had a number of submissions for Javascript or Typescript drivers
in the past, but none of them were followed through to be integrated.

Typescript:

https://lore.kernel.org/git/20240404163827.5855-1-utsavp0213@gmail.com/
https://lore.kernel.org/git/pull.1746.git.git.1721061218993.gitgitgadget@gmail.com/

Javascript:

https://lore.kernel.org/git/20240301074048.188835-1-sergiusnyah@gmail.com/
https://lore.kernel.org/git/20220403132508.28196-1-a97410985new@gmail.com/
https://lore.kernel.org/git/20250604094100.80598-1-derick.william.moraes@gmail.com/

Please review these submission and the responses that they received.
Perhaps you can find inspiration for improvement from them.

-- Hannes

@gitgitgadget-git
Copy link
Copy Markdown

Ben Knoble wrote on the Git mailing list (how to reply to this email):

> Le 29 mars 2026 à 05:32, Johannes Sixt <j6t@kdbg.org> a écrit :
> 
> Javascript and Typescript are related languages, if I am not mistaken.
> 
> -- Hannes

FWIW, I believe both languages are officially spelled with a capital S: “JavaScript”, “TypeScript”. At least that is how Wikipedia and official sites present them.

I knew what you meant of course, and will now take my pedant hat off ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants