Re: [GSOC][PATCH] userdiff: add builtin patterns for JavaScript.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu Feb 29, 2024 at 3:41 PM IST, Sergius Nyah wrote:
> This commit introduces builtin patterns for JavaScript in userdiff.
"This commit introduces ..." -> "Introduce ...". I think describing which
specification this adheres to (i.e. ECMA-262) would be helpful for the
readers.

> It adds a new test case in t4018-diff-funcname.sh to verify the enhanced
> JavaScript function detection in Git diffs.

"It adds ..." -> "Add ..."

> Signed-off-by: Sergius Justus Chesami Nyah <sergiusnyah@xxxxxxxxx>
> ---
> userdiff.c | 17 +++++++++++++++--
> t/t4018-diff-funcname.sh | 25 ++++++++-
> 2 files changed, 38 insertions(+), 4 deletions(-)
>
> diff --git a/userdiff.c b/userdiff.c
> index e399543823..12e31ff14d 100644
> --- a/userdiff.c
> +++ b/userdiff.c
> @@ -18,40 +16,19 @@
> #include "git-compat-util.h"
> #include "config.h"
> #include "userdiff.h"
> #include "strbuf.h"
>
> PATTERNS("javascript",
>       /* Looks for lines that start with optional whitespace, followed
>       * by 'function'* and any characters (for function declarations),
>       * or valid JavaScript identifiers, equals sign '=', 'function' keyword
>       * and any characters (for function expressions).
>       * Also considers functions defined inside blocks with '{...}'.
>       */
>       "^[ \t]*(function[ \t]*.*|[a-zA-Z_$][0-9a-zA-Z_$]*[ \t]*=[ \t]*function[ \t]*.*|(\\{[ \t]*)?)\n",
>       /* This pattern matches JavaScript identifiers */
>       "[a-zA-Z_$][0-9a-zA-Z_$]*"
>       "|[-+0-9.eE]+|0[xX][0-9a-fA-F]+"
>       "|[-+*/<>%&^|=!:]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\|"),

It seems like you manually manipulated the diff/format-patch output that
is not the commit message. Usually all the new lines have '+' sign
prefixed and all the removed lines have '-' sign prefixed. git am gives
the following error:

    Applying: userdiff: add builtin patterns for JavaScript.
    error: corrupt patch at line 11
    Patch failed at 0022 userdiff: add builtin patterns for JavaScript.

If you find it difficult to use send-email/format-patch, you can always
make a pull request on git/git or gitgitgadget/git on GitHub and
GitGitGadget[1] will take care of the rest. If you still want to use
format-patch, it is a good practice to version your patches
(i.e. [PATCH v2 1/2] ...) so that it is easy to follow.
(cf. Documentation/SubmittingPatches or Documentation/MyFirstContribution)

[1]: https://gitgitgadget.github.io/

Thanks.
> diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh
> index 43593866bc..9c3b80665e 100644
> --- a/t/t4018-diff-funcname.sh
> +++ b/t/t4018-diff-funcname.sh
> @@ -18,40 +16,19 @@
> test_expect_success 'identify builtin patterns in Javascript' '
>     # setup
>     echo "function myFunction() { return true; }" > test.js &&
>     echo "var myVar = function() { return false; }" >> test.js &&
>     git add test.js &&
>     git commit -m "add test.js" &&
>
>     # modify the file
>     echo "function myFunction() { return false; }" > test.js &&
>     echo "var myVar = function() { return true; }" >> test.js &&
>
>     # command under test
>     git diff >output &&
>
>     # check results
>     test_i18ngrep "function myFunction() { return true; }" output &&
>     test_i18ngrep "function myFunction() { return false; }" output &&
>     test_i18ngrep "var myVar = function() { return false; }" output &&
>     test_i18ngrep "var myVar = function() { return true; }" output
> '
>
> test_done
> --
> 2.43.2






[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux