Get git blame
information for methods and classes, by code or by launching a graphical interface on current file in method editor using macro.
To install this component into your 4D, download it, rename it with .4dbase
extension and move it manually to the Components
folder of your 4D app or into your database.
or use kaluza command line interface and do kaluza install -g mesopelagique/Blame4D
or v19 component DeployComponent
This component add two macro to display blame result on current method or class.
This macro launch the native git gui blame graphical interface on current method.
On macOs to upgrade git you could use
brew install git-gui
with brew
This macro launch the a 4D form with blame result on current method.
This form have not all functionnalities of git blame gui
, but this do the job for most cases.
4D macro system seems to not allow me to get selected lines, so I cannot limit blame to selected lines.
$blame:=blame($blameOut)
with $blameOut
the result of the git blame operation using -p (porcelain) option.
For instance git blame -p 'Project/Sources/Classes/Blame.4dm'
You could launch git command with
LAUNCH EXTERNAL PROCESS
// Get the commit data object
$commitData = $blame.commitData
// Get the line data object
// each item containing a reference(the hash) to commits that can be then referenced in commitData
$lineData = $blame.lineData
$lineData = $blame.data(5)
It's equivalient to $lineData["5"]
merged with $commitData[$lineData["5"].hash]
$blame:=blameMethod($methodPath) // for instance blameMethod(Current method path)
Code to parse blame output converted from Javascript project blamejs with Mesopotamia