<?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>Forem: Sakthivel Balasubramaniam</title>
    <description>The latest articles on Forem by Sakthivel Balasubramaniam (@imshakthi).</description>
    <link>https://forem.com/imshakthi</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%2F172949%2F04452809-1d74-42f1-9cd0-ac8689187d37.jpg</url>
      <title>Forem: Sakthivel Balasubramaniam</title>
      <link>https://forem.com/imshakthi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/imshakthi"/>
    <language>en</language>
    <item>
      <title>Git - Validate commit message - git hooks</title>
      <dc:creator>Sakthivel Balasubramaniam</dc:creator>
      <pubDate>Fri, 14 May 2021 10:28:38 +0000</pubDate>
      <link>https://forem.com/imshakthi/git-validate-commit-message-git-hooks-5aho</link>
      <guid>https://forem.com/imshakthi/git-validate-commit-message-git-hooks-5aho</guid>
      <description>&lt;p&gt;To enforce commit messages in git repo to follow specific format or pattern. This can be achieve by using &lt;code&gt;git-hooks&lt;/code&gt;, where the commit message is formatted with the help of &lt;code&gt;commit-msg&lt;/code&gt; hook. commit-msg hook will be trigger on each commit.&lt;/p&gt;

&lt;p&gt;First go to git repo which needs the validator, then create &lt;code&gt;commit-msg&lt;/code&gt; hook file in &lt;code&gt;.git/hooks&lt;/code&gt; folder&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="nb"&gt;cd&lt;/span&gt; &amp;lt;path-to-git-repo-to-install-commit-message-validator&amp;gt;

&lt;span class="nb"&gt;touch&lt;/span&gt; .git/hooks/commit-msg
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Modify permission to make the hook executable&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chmod +x .git/hooks/commit-msg
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open &lt;code&gt;commit-msg&lt;/code&gt; file in a editor and add the following lines of script.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="c1"&gt;#!/usr/bin/env ruby&lt;/span&gt;
&lt;span class="n"&gt;message_file&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;ARGV&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;File&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;message_file&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="vg"&gt;$regex&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sr"&gt;/((\w):\s(\w))/i&lt;/span&gt; 
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="vg"&gt;$regex&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;match&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
  &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;"[POLICY] Your message is not formatted correctly"&lt;/span&gt; 
  &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;"[STANDARD] Your message should be in the format: ‘committer_name: commit message’"&lt;/span&gt; 
  &lt;span class="nb"&gt;exit&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Create hook installer
&lt;/h3&gt;

&lt;p&gt;A simple hook installer can be created as follows, here I have used quite a complex pattern.&lt;/p&gt;

&lt;p&gt;Customize the &lt;code&gt;$regex&lt;/code&gt; found in the script as per need. Existing regex is designed to handle &lt;code&gt;PROJECT-#### [committer_name_1|committer_name_2] commit message&lt;/code&gt; pattern, which can be replaced.&lt;/p&gt;

&lt;p&gt;To install &lt;code&gt;commit-msg-validator.sh&lt;/code&gt; use the following commands&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="nb"&gt;cd&lt;/span&gt; &amp;lt;path-to-git-repo-to-install-commit-message-validator&amp;gt;

wget https://raw.githubusercontent.com/ImShakthi/hackrator/master/git-hooks/commit-msg-validator.sh

&lt;span class="nb"&gt;chmod&lt;/span&gt; +x commit-msg-validator.sh

sh commit-msg-validator.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hola, commit message validator would be installed successfully.&lt;/p&gt;

</description>
      <category>github</category>
      <category>githooks</category>
      <category>tricks</category>
    </item>
    <item>
      <title>PlantUML is awesome</title>
      <dc:creator>Sakthivel Balasubramaniam</dc:creator>
      <pubDate>Sun, 08 Sep 2019 09:37:14 +0000</pubDate>
      <link>https://forem.com/imshakthi/plantuml-is-awesome-14aj</link>
      <guid>https://forem.com/imshakthi/plantuml-is-awesome-14aj</guid>
      <description>&lt;p&gt;This post is all about why I felt PlantUML is awesome.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/plantuml/plantuml" rel="noopener noreferrer"&gt;PlantUML&lt;/a&gt; is an open-source tool allowing users to create UML diagrams from a plain text language.&lt;/p&gt;

&lt;p&gt;You can just write few lines of code to draw your UML diagram. UML diagrams are very important in communicating design implementation, doing these digrams in draw.io or something drawing tool is a time taking task. Playing with touchpad/mouse for long time is less effective.&lt;/p&gt;

&lt;p&gt;I have used similar tools in past, like &lt;a href="https://github.com/knsv/mermaid" rel="noopener noreferrer"&gt;mermaid&lt;/a&gt; and &lt;a href="https://graphviz.org/" rel="noopener noreferrer"&gt;graphviz&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Following are the things that made PlantUML different&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Readability&lt;/li&gt;
&lt;li&gt;Maintainable&lt;/li&gt;
&lt;li&gt;Flexible&lt;/li&gt;
&lt;li&gt;Powerful&lt;/li&gt;
&lt;li&gt;Customable&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once the UML is designed with plantUML the end result can be extracted out into PNG or SVG. There are plugins that can be easily intergated into IDE's, such as &lt;a href="https://marketplace.visualstudio.com/items?itemName=jebbs.plantuml" rel="noopener noreferrer"&gt;PlantUML for VS Code&lt;/a&gt; and &lt;a href="https://plugins.jetbrains.com/plugin/7017-plantuml-integration" rel="noopener noreferrer"&gt;PlantUML for IntelliJ&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Also available for &lt;a href="https://www.atlassian.com/software/confluence" rel="noopener noreferrer"&gt;Confluence&lt;/a&gt;(document manager of Atlassian suite) where the history of the change in design implementation can be tracked easily &lt;a href="https://marketplace.atlassian.com/apps/41025/plantuml-for-confluence?hosting=server&amp;amp;tab=overview" rel="noopener noreferrer"&gt;PlantUML for Confluence&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;PS: PlantUML is written is java with graphviz underhood :)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;PlantUML is a component that allows to quickly write :&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Sequence diagram&lt;/li&gt;
&lt;li&gt;Usecase diagram&lt;/li&gt;
&lt;li&gt;Class diagram&lt;/li&gt;
&lt;li&gt;Activity diagram (here is the legacy syntax)&lt;/li&gt;
&lt;li&gt;Component diagram&lt;/li&gt;
&lt;li&gt;State diagram&lt;/li&gt;
&lt;li&gt;Object diagram&lt;/li&gt;
&lt;li&gt;Deployment diagram &lt;code&gt;beta&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Timing diagram &lt;code&gt;beta&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can find the details &lt;a href="http://plantuml.com/" rel="noopener noreferrer"&gt;documentation&lt;/a&gt; of how and what is plantUML.&lt;/p&gt;

&lt;p&gt;Here I took a random sequence diagram from internet and tried to replicate the same in PlantUML with few tweeks, the end result was wow!&lt;/p&gt;

&lt;h2&gt;
  
  
  Sample Sequence diagram
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FPqvRnKNP%2Fsequence-example-facebook-authentication.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FPqvRnKNP%2Fsequence-example-facebook-authentication.png" alt="sample sequnce"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Sequence diagram with PlantUML
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2F4NtvGM1C%2Ffacebook.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2F4NtvGM1C%2Ffacebook.png" alt="PlantUML sequnce"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's not just a replica, but a much better one.&lt;/p&gt;

&lt;p&gt;Here the code that did the &lt;code&gt;magic&lt;/code&gt; for us.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@startuml
header Facebook Authentication System
title Facebook Authentication System
footer Page no %page% of %lastpage%

actor user #3c5a99
participant WebBrowser as "Web Browser"
box "Facebook server"
    participant App as "Application"
    participant AuthZ as "Authorization System"
    database FCS as "Facebook Content System"
end box

== Basic flow ==

activate user
user -&amp;gt; WebBrowser : get FB resource
    activate WebBrowser
        WebBrowser -&amp;gt; App : request FB access
        WebBrowser &amp;lt;-- App : &amp;lt;&amp;lt;http redirect&amp;gt;&amp;gt;
        WebBrowser -[#red]&amp;gt; AuthZ : authorize
        WebBrowser &amp;lt;-- AuthZ : permission form
        user &amp;lt;-- WebBrowser : permission form
    deactivate WebBrowser

    user -&amp;gt; WebBrowser : user permission
    activate WebBrowser
        WebBrowser -&amp;gt; AuthZ : process permission
        ... 5 minutes alter ...
        WebBrowser &amp;lt;-- AuthZ : &amp;lt;&amp;lt;http redirect&amp;gt;&amp;gt;

        == Authorization ==
        alt permission granted
            activate App
                group
                WebBrowser -&amp;gt; App : FB authorization code
                        activate AuthZ
                            App -&amp;gt;  AuthZ : FB authorization code
                            App &amp;lt;--  AuthZ : FB authorization code
                        deactivate AuthZ

                        activate FCS
                            App -&amp;gt; FCS : access FB user protected resource
                            App &amp;lt;-- FCS : user protected resource
                            note left FCS: Check with content system
                        deactivate FCS
                 end
            deactivate App

            WebBrowser &amp;lt;-- App : user protected resource
            deactivate WebBrowser

            user &amp;lt;-- WebBrowser  : user protected resource
        else permission not granted
            activate WebBrowser
                activate App
                    WebBrowser -&amp;gt; App : no authorization
                    WebBrowser &amp;lt;-- App : FB resource not available
                deactivate App
            deactivate WebBrowser

            user &amp;lt;-- WebBrowser  : FB resource not available
        end
    deactivate WebBrowser

deactivate user
@enduml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Thanks for reading!!!&lt;br&gt;
:)&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>design</category>
    </item>
  </channel>
</rss>
