<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Shreyas Minocha</title>
    <description>The latest articles on DEV Community by Shreyas Minocha (@shreyasminocha).</description>
    <link>https://dev.to/shreyasminocha</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F28331%2F7266585b-3bd2-4b13-8ea2-95b0fcd99d1e.png</url>
      <title>DEV Community: Shreyas Minocha</title>
      <link>https://dev.to/shreyasminocha</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/shreyasminocha"/>
    <language>en</language>
    <item>
      <title>What do you think about the ternary operator?</title>
      <dc:creator>Shreyas Minocha</dc:creator>
      <pubDate>Sun, 05 Aug 2018 09:28:14 +0000</pubDate>
      <link>https://dev.to/shreyasminocha/what-do-you-think-about-the-ternary-operator-5ajg</link>
      <guid>https://dev.to/shreyasminocha/what-do-you-think-about-the-ternary-operator-5ajg</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Felqlaga0lcskawkd0k50.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Felqlaga0lcskawkd0k50.png" alt="Shortcuts" width="800" height="495"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The ternary operator has a reputation of reducing readability. However, in the right hands, it may result in less duplication.&lt;/p&gt;

&lt;p&gt;Do you think it's use has enough of a negative impact on readability? Are there enough legitimate use cases do justify the potential misuse? &lt;/p&gt;

&lt;p&gt;How often do you use it? Have you seen it used in contexts where it aids readability? &lt;/p&gt;

&lt;p&gt;Do you think modern programming languages should come with it? Users of languages without the ternary operator (golang etc), do you miss it?&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>practices</category>
      <category>programming</category>
    </item>
    <item>
      <title>My commit message workflow</title>
      <dc:creator>Shreyas Minocha</dc:creator>
      <pubDate>Fri, 22 Jun 2018 14:38:43 +0000</pubDate>
      <link>https://dev.to/shreyasminocha/how-i-do-my-git-commits-34d</link>
      <guid>https://dev.to/shreyasminocha/how-i-do-my-git-commits-34d</guid>
      <description>&lt;p&gt;&lt;em&gt;This article was originally published on &lt;a href="http://shreyasminocha.me/blog" rel="noopener noreferrer"&gt;http://shreyasminocha.me/blog&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2bfo8veyf8130o34mtqi.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2bfo8veyf8130o34mtqi.jpg" alt="Commit message example" width="800" height="458"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I totally obsess over commit messages. I often spend minutes staring into space trying to come up with the best way to summarize the changes a commit brings. I religiously follow &lt;a href="////chris.beams.io/posts/git-commit/#seven-rules"&gt;the seven rules of good commit messages&lt;/a&gt;. As you might have guessed, I've spent some time developing a workflow for writing commit messages.&lt;/p&gt;

&lt;p&gt;I use Sublime Text 3 for most of my text-editing needs. I've also set it as my core editor.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git config &lt;span class="nt"&gt;--global&lt;/span&gt; core.editor &lt;span class="s2"&gt;"subl -n -w"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: The above requires the you to install the &lt;code&gt;subl&lt;/code&gt; command if it doesn't work out of the box. Installation instructions: &lt;a href="////stackoverflow.com/questions/16199581/open-sublime-text-from-terminal-in-macos"&gt;macOS&lt;/a&gt; · &lt;a href="////askubuntu.com/a/274197"&gt;Linux&lt;/a&gt; · &lt;a href="////stackoverflow.com/a/25577833/3363528"&gt;Windows&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Earlier, I used to use &lt;a href="////packagecontrol.io/packages/Git%20Commit%20Message%20Syntax"&gt;a package&lt;/a&gt; to provide syntax highlighting for commit messsages. However, build 3170 has brought native support for various git formats, commit message included.&lt;/p&gt;

&lt;p&gt;Sublime allows you to override settings for specific syntaxes. You can edit these from ‹Preferences› → ‹Settings – Syntax Specific›. Here's my &lt;code&gt;Git Commit.sublime-settings&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"rulers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;72&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"spell_check"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"word_wrap"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"true"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"wrap_width"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;72&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"font_size"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;14&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"draw_centered"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: VS Code fans can do it &lt;a href="////github.com/Microsoft/vscode-docs/blob/master/docs/getstarted/tips-and-tricks.md#language-specific-settings"&gt;this way&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Somewhere on the internet, I found a template for commit messages:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# If applied, this commit will…&lt;/span&gt;


&lt;span class="c"&gt;# Explain why this change is being made&lt;/span&gt;

&lt;span class="c"&gt;# Provide links to any relevant tickets, articles or other resources&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This template makes it easier to frame commits in accordance with the seven rules I mentioned earlier. I can't seem to remember &lt;em&gt;where&lt;/em&gt; I found this, but in my attempts to trace it, I found &lt;a href="////codeinthehole.com/tips/a-useful-template-for-commit-messages"&gt;a blog post&lt;/a&gt; providing a very similar template. As it turns out, git allows you to use a text file as a template for your commit messages.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git config &lt;span class="nt"&gt;--global&lt;/span&gt; commit.template &lt;span class="s2"&gt;"/Users/example/dotfiles/commit-msg-template"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When I started using this template, I had a small pet peeve about my setup. Running &lt;code&gt;git commit&lt;/code&gt; would fire up Sublime with the cursor on the first line and to actually &lt;em&gt;write&lt;/em&gt; the message, I would have to move the cursor one line below. With research and some experimentation, I solved the issue:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git config &lt;span class="nt"&gt;--global&lt;/span&gt; core.editor &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"sublime -n -w &lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="s2"&gt;:2"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;$1:2&lt;/code&gt; at the end of the value opens the argument with the cursor on row 2.&lt;/p&gt;

&lt;p&gt;Another one of my pet-peeves with the commit message text is this little snippet above the commented out &lt;code&gt;git status&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Please enter the commit message for your changes. Lines starting&lt;/span&gt;
&lt;span class="c"&gt;# with '#' will be ignored, and an empty message aborts the commit.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;While helpful to the newbie, this little notice ended up becoming an annoyance. I found a &lt;a href="////stackoverflow.com/a/3967136"&gt;helpful answer on StackOverflow&lt;/a&gt; which advised using a &lt;a href="////git-scm.com/docs/githooks#_prepare_commit_msg"&gt;global &lt;code&gt;prepare-commit-msg&lt;/code&gt; hook&lt;/a&gt;. If you don't already have a global git hooks directory, create one and tell git about it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git config &lt;span class="nt"&gt;--global&lt;/span&gt; core.hookspath &lt;span class="s2"&gt;"/Users/example/dotfiles/git-hooks"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create &lt;code&gt;prepare-commit-msg&lt;/code&gt; in said directory with the following content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;

&lt;span class="nb"&gt;sed&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt;.bak &lt;span class="s1"&gt;'/^# Please/,/^#$/ d'&lt;/span&gt; &lt;span class="nv"&gt;$1&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;rm&lt;/span&gt; &lt;span class="nv"&gt;$1&lt;/span&gt;.bak
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Edit: This snippet originally used &lt;code&gt;perl&lt;/code&gt; followed by &lt;code&gt;grep&lt;/code&gt;. Thanks &lt;a class="mentioned-user" href="https://dev.to/shaiay"&gt;@shaiay&lt;/a&gt; and &lt;a class="mentioned-user" href="https://dev.to/jwmevans_77"&gt;@jwmevans_77&lt;/a&gt;'s for your suggestions in the comments.&lt;/p&gt;

&lt;p&gt;Make sure the hook is set to be executable with &lt;code&gt;chmod +x&lt;/code&gt;. Now that pesky help notice will bother you no more.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgczdqj514tcob6r8st2f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgczdqj514tcob6r8st2f.png" alt="Relevant xkcd" width="439" height="250"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Recently, I found &lt;a href="////github.com/clns/node-commit-msg"&gt;this really cool utility&lt;/a&gt; which allows you to validate commit messages from the command line. I use a modified form of the utility in a &lt;a href="////git-scm.com/docs/githooks#_commit_msg"&gt;global &lt;code&gt;commit-msg&lt;/code&gt; hook&lt;/a&gt; to automatically validate every commit I make. Create &lt;code&gt;commit-msg&lt;/code&gt; in your global git hooks directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;

commit-msg file &lt;span class="nv"&gt;$1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: The above requires the &lt;code&gt;commit-msg&lt;/code&gt; command to be on your &lt;code&gt;$PATH&lt;/code&gt;. Install it using &lt;code&gt;npm i -g commit-msg&lt;/code&gt; manually from &lt;a href="////github.com/clns/node-commit-msg"&gt;source code&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Again, make sure the script is set to be executable. The result of this hook is that the commit would abort if my commit message does not meet the criteria.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flymt8e0rtm3prum5xv3f.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flymt8e0rtm3prum5xv3f.jpg" alt="An example of an invalid commit message" width="800" height="216"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks for reading!&lt;/p&gt;

&lt;h2&gt;
  
  
  Further reading
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html" rel="noopener noreferrer"&gt;Tim Pope's note about commit messages&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.git-scm.com/book/en/v2/Distributed-Git-Contributing-to-a-Project#_commit_guidelines" rel="noopener noreferrer"&gt;Commit guideline suggestions from Pro Git&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/torvalds/subsurface-for-dirk/blob/master/README#L92-L120" rel="noopener noreferrer"&gt;Linus Torvald's note about commit messages&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/spring-projects/spring-framework/blob/30bce7/CONTRIBUTING.md#format-commit-messages" rel="noopener noreferrer"&gt;Commit message formatting guidelines from the Spring Project&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>git</category>
      <category>productivity</category>
      <category>workflow</category>
    </item>
  </channel>
</rss>
