简体   繁体   中英

Git log with Json hierarchy

The problem is that I have this git command

git log --pretty=format:'%n{%n%d%n  "CommitHash": "%H",%n  "Author": 
    "%an",%n  "AuthorEmail": "%ae",%n  "Date": "%ad",%n  "Message": "%f"%n}'

` with it, I get a log with a JSON format, but I need to get the branches as fathers and the commits names as children, and those commits names must be fathers they respective info(author, date, email, etc.....)

The log output should be something like this:

[
  "Branch or Merge Name":"The Branch or Merge Name"[
       "Commit Name":"The Commit Name"{
               The commit info......
          }
   ]
]

I doubt this would be easy to do without a script, considering a commit can be part of multiple branches .

That means for any commit of your list, there is not "one father", but possibly multiple ones.

Reversing the model, and having for each commit, as a child, the list of branches each commit is part of, would make more sense.

Look at this tool http://bit-booster.com/graph.html they pass the log to you in git format log --pretty = '% h |% p |% d' I'm trying to do apache echart. --pretty = "% H,% P,% D"

% H expands to show the commitId.

% P expands to show the parent commitIds.

% D expands to show the decorations (tags and branches).

But there are a few subtle problems with it:

% P will expand to all of% H's parent commits (separated by space), and so you'll need to run the output through a 2nd script to better normalize that into a format suitable for D3.

% P might expand to 3 or more commits (very rare). These are called octopus merges!

% D expands to a comma separated list of decorations (branch and tag labels), and there's no limit on how many branches and tags a single commit might have.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM