gitgraph.js
gitgraph.js copied to clipboard
Branch without commit doesn't show up
Describe the bug
IMHO a branch that has no new commit yet should still show up
the following code creates 2 branches, but devel
won't show up in the output image;
it is still a valid branch, as any git UI would show
To Reproduce
<!DOCTYPE html>
<html>
<head>
<!-- Load the JS file -->
<script src="./gitgraph.umd.min.js"></script>
</head>
<body>
<!-- DOM element in which we'll mount our graph -->
<div id="graph-container"></div>
<!-- Use the `GitgraphJS` global variable to create your graph -->
<script>
// Get the graph container HTML element.
const graphContainer = document.getElementById("graph-container");
// Instantiate the graph.
const gitgraph = GitgraphJS.createGitgraph(graphContainer);
// Simulate git commands with Gitgraph API.
const master = gitgraph.branch("master");
master.commit("Initial commit");
master.commit("Second commit");
let devel = gitgraph.branch("devel");
master.commit("Third commit");
master.commit("Fourth commit");
</script>
</body>
</html>
I do see this:
Expected behavior
I would expect something like this
Thanks for raising it @parmentelat.
It's a known issue indeed, I thought we have an issue tracking it, but I can't find it so I guess we didn't. This need to be fixed indeed has the branch would show up in any git GUI / git log.
It's a known issue indeed, I thought we have an issue tracking it, but I can't find it so I guess we didn't. This need to be fixed indeed has the branch would show up in any git GUI / git log.
Maybe you are thinking of #258 ? Seems similar IMO.
As mentioned, only one label will show up per commit.
However the line between commits is also not drawn when you fork from the ignored branch -- this looks to be the same root cause
Demo: https://codepen.io/codepeon/pen/bXWLmo
const gitgraph = new GitGraph();
const currentrelease = gitgraph.branch("currentrelease");
currentrelease.commit("commit1");
// master and live refer to the same commit
const nextrelease = currentrelease.branch("nextrelease");
// If you uncomment this then it works as you would expect
// nextrelease.commit("commit2");
const branch = nextrelease.branch("branch1");
branch.commit("commit3")
branch.merge(nextrelease);