Blame4D
Get git blame
information for methods and classes, by code or by launching a graphical interface on current file in method editor using macro.
Install component
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
Macro
This component add two macro to display blame result on current method or class.
Blame GUI
This macro launch the native git gui blame graphical interface on current method.
- https://git-scm.com/docs/git-gui
- https://github.com/prati0100/git-gui/
On macOs to upgrade git you could use
brew install git-gui
with brew
Blame Form
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.
Limitation
4D macro system seems to not allow me to get selected lines, so I cannot limit blame to selected lines.
How to by code
From command output
$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 lines and commit data
// 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
Get data for a specific line
$lineData = $blame.data(5)
It’s equivalient to $lineData["5"]
merged with $commitData[$lineData["5"].hash]
From method path in current database
$blame:=blameMethod($methodPath) // for instance blameMethod(Current method path)
Acknowledgement
Code to parse blame output converted from Javascript project blamejs with Mesopotamia