Skip to main content

Add some depth to `git blame`

Project description

https://travis-ci.com/Kraymer/ublame.svghttps://travis-ci.com/Kraymer/ublame https://coveralls.io/repos/github/Kraymer/ublame/badge.svg?branch=mainhttps://coveralls.io/github/Kraymer/ublame https://img.shields.io/github/v/release/kraymer/ublame.svghttps://github.com/Kraymer/ublame/releases https://img.shields.io/badge/-%E2%99%A1%20Donate%20-ff69b4https://www.patreon.com/kraymer

Ublame

http://media1.britannica.com/eb-media/81/161281-004-F4CE9CF0.jpg

Artist’s rendering of the bathyscaphe Trieste – britannica.com

/ˈublaːm(ə)/ :

git blamewith some depth.
Portmanteau word from :
1. u-boat: anglicised version of the German word U-Boot that refers to any submarine
2. blame: git command that annotate each line in a given file with information from the revision which last modified the line.

Install

cronicle is written for Python 3.6+ and is tested on Linux.

Install with pip via pip3 install ublame command.

Why

ublame is born from the frustration of using git blame to track the successive editors of a code segment. It performs a search on a file commits history and reports all the revisions that contain searched term in their diffs.

See SO question Git blame — prior commits?

https://github.com/Kraymer/public/blob/master/ublame_why.png?raw=true

Example

The last modification is not always the information you need when you try to grasp a piece of code.

❯ git blame tests/rsrc/example.py | grep "if token in diff"

e65d24b3 (Fabrice Laporte 2020-11-04 2132 +0100  8)     if token in diff:

❯ git show e65d24b3
commit e65d24b336570822d33f91847542743969b17fa2 (HEAD -> main)
Author: Fabrice Laporte
Date:   Wed Nov 4 2132 2020 +0100

    chore: convert tabs to spaces

In that example, the last commit modified the code only to convert tabs to spaces and previous commits that were probably more interesting to get the original intention of the developer(s) are not captured by git blame. So you need to apply git blame on the version of the file preceding e65d24b3 and so on …

With ublame the information is instantly available in one command :

❯ ublame tests/rsrc/example.py "if token in diff"

Commit: e65d24b336570822d33f91847542743969b17fa2
Author: Fabrice Laporte
Date: 2020-11-04 2233+01:00

    chore: convert tabs to spaces

 def trim_diff(diff, token):
-       """Keep only context surrounding searched token.
-       """
-       if token in diff:
-               LOC_BEFORE = LOC_AFTER = 3
-       lines = diff.split("\n")

Commit: 01c5f3e2a91bcffbb5bdb24cac20d76f98b33db4
Author: Fabrice Laporte <fabrice@yescapa.com>
Date: 2020-11-04 2230+01:00

    tests: add example.py

+def trim_diff(diff, token):
+       """Keep only context surrounding searched token.
+       """
+       if token in diff:
+               LOC_BEFORE = LOC_AFTER = 3
+       lines = diff.split("\n")

Screenshot

https://github.com/Kraymer/public/blob/master/ublame_screenshot.png?raw=true

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ublame-0.1.0.tar.gz (5.3 kB view hashes)

Uploaded Source

Built Distribution

ublame-0.1.0-py3-none-any.whl (4.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page