<?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: Xianying</title>
    <description>The latest articles on DEV Community by Xianying (@xianyings).</description>
    <link>https://dev.to/xianyings</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4051713%2F229a965b-ece0-4140-9fab-e0100da3977e.png</url>
      <title>DEV Community: Xianying</title>
      <link>https://dev.to/xianyings</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/xianyings"/>
    <language>en</language>
    <item>
      <title>I made git blame apologize on my behalf</title>
      <dc:creator>Xianying</dc:creator>
      <pubDate>Tue, 28 Jul 2026 16:09:54 +0000</pubDate>
      <link>https://dev.to/xianyings/i-made-git-blame-apologize-on-my-behalf-5bbp</link>
      <guid>https://dev.to/xianyings/i-made-git-blame-apologize-on-my-behalf-5bbp</guid>
      <description>&lt;p&gt;Every codebase has a line that makes you recoil. A nested ternary, three levels deep, inside an authorization check, returning &lt;code&gt;true : false&lt;/code&gt; inside another condition — with a comment above it reading &lt;em&gt;"Do not change without asking me."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The usual next move is &lt;code&gt;git blame&lt;/code&gt;, followed by an awkward conversation. Sometimes that conversation is with yourself, because the name that comes back is your own.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git-sorry&lt;/code&gt; handles the awkward part for you, and makes it funny enough that nobody gets defensive.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I built
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;git-sorry&lt;/code&gt; takes a file and a line number, runs &lt;code&gt;git blame&lt;/code&gt;, and works out whether the guilty party is you or someone else. Then it asks Gemini to write the appropriate response — a grovelling apology if the line is yours, a roast if it belongs to a teammate — and posts it to your team's Slack or Discord.&lt;/p&gt;

&lt;p&gt;Here is an actual run against exactly that kind of line, attributed to a fictional colleague named Marcus:&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fgrnktmf00rief9ncgmbb.gif" 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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fgrnktmf00rief9ncgmbb.gif" alt="git-sorry blaming line 42 of src/auth.ts and printing a formal roast in the terminal" width="799" height="415"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That output is unedited. The roast is whatever the model came up with that afternoon.&lt;/p&gt;

&lt;h2&gt;
  
  
  Trying it
&lt;/h2&gt;

&lt;p&gt;You need a free Gemini API key from &lt;a href="https://aistudio.google.com/app/apikey" rel="noopener noreferrer"&gt;Google AI Studio&lt;/a&gt;. Nothing else — no install, and no webhook if you use &lt;code&gt;--dry-run&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;npx git-sorry config &lt;span class="nt"&gt;--set-key&lt;/span&gt; &amp;lt;GEMINI_API_KEY&amp;gt;
npx git-sorry blame src/auth.ts 42 &lt;span class="nt"&gt;--dry-run&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;--dry-run&lt;/code&gt; prints the verdict in your terminal and tells nobody, which I recommend for your first attempt, because you do not yet know what it is going to say about you.&lt;/p&gt;

&lt;p&gt;When you are ready to involve other people:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git-sorry config &lt;span class="nt"&gt;--set-webhook&lt;/span&gt; &amp;lt;SLACK_OR_DISCORD_WEBHOOK_URL&amp;gt;
git-sorry blame src/auth.ts 42
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are two flags for when you want to override fate: &lt;code&gt;--roast&lt;/code&gt; roasts the author regardless of who wrote the line, and &lt;code&gt;--apology&lt;/code&gt; makes you grovel even when it was not your fault.&lt;/p&gt;

&lt;h2&gt;
  
  
  How it works
&lt;/h2&gt;

&lt;p&gt;It is a small thing, deliberately. About 250 lines of TypeScript.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git blame -L &amp;lt;n&amp;gt;,&amp;lt;n&amp;gt; --porcelain&lt;/code&gt; gives the author, the date, and the source line. That gets compared against your local &lt;code&gt;git config user.name&lt;/code&gt; to decide apology or roast. The prompt goes to Gemini Flash, the reply gets wrapped in a box with &lt;code&gt;boxen&lt;/code&gt;, and then it is posted to your webhook.&lt;/p&gt;

&lt;p&gt;The one detail I am quietly pleased with: Slack reads the &lt;code&gt;text&lt;/code&gt; field of a webhook payload and Discord reads &lt;code&gt;content&lt;/code&gt;. Send a body containing both and the same single request works for either service, with no branching and no config asking which one you use.&lt;/p&gt;

&lt;p&gt;Native &lt;code&gt;fetch&lt;/code&gt; handles the request, so there is no HTTP dependency. Config lives in a plain JSON file with owner-only permissions, so there is no config library either. Failed calls retry twice, except a rejected API key, which fails immediately because no amount of retrying will fix a wrong key.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why bother
&lt;/h2&gt;

&lt;p&gt;The honest answer is that it started as a joke and then turned out to be a slightly useful one.&lt;/p&gt;

&lt;p&gt;Blame culture in code review is mostly about tone. A message that says "who wrote this" lands badly. A message that says "Marcus, darling, I didn't know logic gates could express a mid-life crisis" somehow lands fine, and the line still gets fixed. Turning the callout into a bit that the whole team is in on makes the actual conversation about the code much easier to have.&lt;/p&gt;

&lt;p&gt;It also makes people read &lt;code&gt;git blame&lt;/code&gt; output, which they otherwise never do.&lt;/p&gt;

&lt;p&gt;Source is on &lt;a href="https://github.com/zuhairadnansutrisno2502-lab/git-sorry" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;, MIT licensed. Pull requests welcome, especially new personalities for the prompt — the current one is stuck somewhere between a theatre critic and a disappointed parent, and I suspect there is a lot of room below that.&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>javascript</category>
      <category>cli</category>
      <category>ai</category>
    </item>
  </channel>
</rss>
