admin管理员组文章数量:1290134
I am working on a commit tree visualization in React using the GitGraph.js library. My goal is to fetch commits, branches, and merge history from the GitHub API and use this data to render a commit tree.
However, I am facing two main problems:
Disconnected data from GitHub API:
When fetching commits (
/repos/{owner}/{repo}/commits
), branches (/repos/{owner}/{repo}/branches
), and merges (/repos/{owner}/{repo}/pulls
), the API does not provide a clear connection between these elements. It's difficult to determine which commit belongs to which branch and how merges should be represented.Merges automatically push all commits to main/master:
When a branch is merged, all previous commits from that branch seem to be included in the main/master branch, making it look like they were always part of it. This affects the visualization, making it hard to distinguish the actual branch history.
My goal is something like on the image but universal repository and commits.
I fetch commits using GET /{owner}/{repo}/commits
I fetch branches using GET /{owner}/{repo}/branches
I fetch pull requests (merges) using GET /{owner}/{repo}/pulls?state=closed
I tried mapping commits to branches by checking the parents field in commit data but ran into issues with merge commits.
Questions:
- How can I properly map commits to branches to ensure an accurate representation of branch history?
- How do I correctly handle merge commits in GitGraph.js to avoid them overriding the commit tree?
- Is there a better way to fetch structured commit history from GitHub API?
本文标签:
版权声明:本文标题:reactjs - How to properly visualize git commit tree in React using GitGraph.js with GitHub API data? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741422764a2377900.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论