<div dir="ltr"><div>Hello mentors,</div><div><br></div><div>Here is the code for my pre-commit hook script. How it works is by default, upon commiting it outputs a warning stating the number of style issues in case there are mismatches.</div><div>The user can trigger the strict mode which gives a more detailed output of the style issues by running adding the mode to the config file ( git config mode "strict") - will document this.<br></div><div><br></div><div><a href="https://github.com/Idadelveloper/rtems/blob/master/hooks/pre-commit">https://github.com/Idadelveloper/rtems/blob/master/hooks/pre-commit</a></div><div><br></div><div>I had already sent some screenshots here on how the outcome looks like. Will love to improve my code based on your feedback and get more suggestions.<br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jun 21, 2021 at 7:05 PM Gedare Bloom <<a href="mailto:gedare@rtems.org">gedare@rtems.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Jun 20, 2021 at 1:13 AM Ida Delphine <<a href="mailto:idadelm@gmail.com" target="_blank">idadelm@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hello everyone,</div><div>I updated the hooks script. About the modes, we have the default, "strict" and "nonstrict" (couldn't think of better names). With the default mode, it prints a warning specifying the number of style issues if any and aborts the commit. With the strict mode, it goes into more detail showing both the formatted and unformatted patch, the number of style issues, and aborts the commit. In the non-strict mode, it simply displays the warning with the style issues and the commit happens.<br></div><div><br></div><div>The default mode basically happens when you run <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>git commit -m "Commit message"</div></blockquote><div>The best method I could find to pass arguments to a script was via environment variables. So the nonstrict mode applies when you run</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>STYLEMODE=nonstrict git commit -m "Commit message"<br></div></blockquote><div>The strict mode applies when you run</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>STYLEMODE=strict git commit -m "Commit message"<br></div></blockquote><div><br></div></div></blockquote><div>What are the possible options to pass arguments? (Maybe, a blog post :)) Reading from a git-config file would be better than environment variables.</div><div><br></div><div>It might be better to share screenshots by a link (e.g., a blog post :)) to avoid hitting the mailing list attachment limits.</div><div><br></div><div>Gedare</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"></div></div>
</blockquote></div>
</blockquote></div></div>
</blockquote></div>