I
I
iv-fyodorov19922016-04-19 16:22:53
PHP
iv-fyodorov1992, 2016-04-19 16:22:53

How to visualize GIT commit graph using php?

there is php.
There is an array with commits from GIT, honestly parsed "git log" and slightly combed out:

[#ID#] => array (
   [HASH] => #HASH#
   [PARRENTS] => array (
      [0] => #PARRENT_HASH_0#
      ...
      [N] => #PARRENT_HASH_N#
   )
   [CHILDS] => array (
      [0] => #CHILD_HASH_0#
      ...
      [N] => #CHILD_HASH_N#
   )
)

#CHILD_HASH_0#, #PARRENT_HASH_0#, #HASH# - hash values ​​of the corresponding
commits #ID# - just the serial number of the commit in the array from 0 to N (where 0 is the most recent and N is the oldest)
In fact, for each commit there is its hash , as well as the hashes of his parents/children (if any).
If the commit has no parents or children, then there will be an empty array
. You need to visualize the history of the branch by analogy with github/bitbucket.
How to do it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
ManWithBear, 2016-04-19
@ManWithBear

git log --graph --oneline
?
UPD. So this is a completely different question.
1) We count the number of days and commits in them. As a result, we get a number that will be the width of the image in points
2) We count the number of branches. Get the height of the image in pixels.
3) Draw commits depending on their branch (row) and date/serial number in the day (column)
4) Merge commits within the same branch
5) For commits with multiple descendants, merge to the corresponding branches (do not forget about the offset in the column)
And here Lots of room for optimizations and improvements

A
Alexey Shumkin, 2016-04-21
@ashumkin

if graphically visualized, thengraphviz

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question