📜 ⬆️ ⬇️

git punish - whose team I always lacked

Sometimes, I want to go to the prompted git blame th colleagues, look them kindly in the eye and talk about sore. At such times, the absence of the git punish seems unimaginable.

At first, I intended to write a post in “I am promoting”, but I really wanted to talk about technical details, so please forgive the link to my git-punish.io collected on my knee.

The task was simple: until the excitement had disappeared, to write something caused by git punish disassembling output of the git blame command and the return link to the online page.

The first thing that came of course
')
git config --global alias.punish "...shell command..."


But it quickly became clear that you would not do much. On the second decision brought someone's good advice on Coderwall. The approach immediately seemed beautiful and free from limitations. It turns out that in any place listed in $PATH can create an executable file git-%command% which will add a new command to git.

It turned out like this:

 #!/bin/bash git blame --line-porcelain $@ | curl --data-binary @- http://git-punish.io/create 


The parameter --line-porcelain includes an extended output for each line, which is convenient to parse. Add to the end user parameters $@ . Then POST all output to git-punish.io/create .

Parsing the output is of little interest, but if you really want to see it here . The terminal displays the short URL generated by the service.

Such are the cases. I will be glad to advice, tips and other blame / punish.

UPD

Just in case a disclaimer, I realized that he is needed here. This is a joke service.

Source: https://habr.com/ru/post/267025/


All Articles