From b5708197cfcc526498053f9a07565a2d77615054 Mon Sep 17 00:00:00 2001 From: Alex Palaistras Date: Thu, 12 Jan 2017 22:31:50 +0000 Subject: [PATCH] Add initial path for primary branch, fix font pitch to 0.5 of height The primary branch (`master` or whichever other branch is the primary) has now an automatic merge path that leads to the beginning of time, much like branches that have been created before the first commit. The font pitch is also fixed to half the height, as is usually the case with monospace fonts. --- grawkit | 8 +++--- tests/01-initial.svg | 8 ++++-- tests/02-master.svg | 16 +++++++---- tests/03-branch.svg | 25 +++++++++------- tests/04-merge.svg | 13 +++++---- tests/05-multi-branch.svg | 57 +++++++++++++++++++------------------ tests/06-feature-branch.svg | 53 ++++++++++++++++++---------------- 7 files changed, 99 insertions(+), 81 deletions(-) diff --git a/grawkit b/grawkit index cc7b2da..5c3a451 100755 --- a/grawkit +++ b/grawkit @@ -103,10 +103,10 @@ function branch(idx, _, buf, tmp, refs, tags, t, i, hspc, vspc) { # > Function `label` adds a sidebar label at commit index, with a specific class # > and label name. Multiple labels for the same index will be placed side-by-side. function label(idx, class, name, _, buf, w, h, hspc, vspc) { - # Calculate width and height for label rectangle. Pitch size is set to 0.525 + # Calculate width and height for label rectangle. Pitch size is set to 0.5 # here, which is approximately right for 'Inconsolata', but may vary for other # fonts, as fixed width fonts are usually twice as tall as they are wide. - w = ((style["label/font-size"] * 0.525) * length(name)) + style["label/spacing"] + w = ((style["label/font-size"] * 0.5) * length(name)) + style["label/spacing"] h = style["label/font-size"] + style["label/spacing"] # Calculate label offsets. @@ -226,14 +226,14 @@ BEGIN { # Branch definitions. branches[0,"name"] = "master" branches[0,"refs"] = "" - branches[0,"merges"] = "" + branches[0,"merges"] = "0|0" branches[0,"tags"] = "" len["branches"] = 1 # Commit definitions. commits[0,"type"] = "" commits[0,"message"] = "" - len["commits"] = 0 + len["commits"] = 1 # Tracks the state across calls. state["branch"] = 0 diff --git a/tests/01-initial.svg b/tests/01-initial.svg index 71bc334..176a0fc 100644 --- a/tests/01-initial.svg +++ b/tests/01-initial.svg @@ -4,7 +4,7 @@ --> - + - + + + + + diff --git a/tests/02-master.svg b/tests/02-master.svg index 4d3b923..26795b3 100644 --- a/tests/02-master.svg +++ b/tests/02-master.svg @@ -7,7 +7,7 @@ git commit --> - + - + + + + + - - + - - + + + master diff --git a/tests/03-branch.svg b/tests/03-branch.svg index a215b5d..ccf84f6 100644 --- a/tests/03-branch.svg +++ b/tests/03-branch.svg @@ -18,7 +18,7 @@ git commit --> - + - + + + + - - + - - + + + test-stuff - - + - - - + + + + master diff --git a/tests/04-merge.svg b/tests/04-merge.svg index 7132113..7919e91 100644 --- a/tests/04-merge.svg +++ b/tests/04-merge.svg @@ -5,7 +5,6 @@ git branch test-merging git commit -m "Commit on master" -git commit -m "Still on master" git checkout test-merging git commit -m 'A sample commit' @@ -17,7 +16,7 @@ git merge test-merging --> - + - + - - + + - - + + + + + - - - - + + + + test-third - - + - - + + + v.2.0.0-rc1 - - + + test-second - - - - + + + + test-first - - + - - - + + + + v.1.0.0 - - + + master diff --git a/tests/06-feature-branch.svg b/tests/06-feature-branch.svg index c81a460..feae1f6 100644 --- a/tests/06-feature-branch.svg +++ b/tests/06-feature-branch.svg @@ -27,7 +27,7 @@ git merge feature/ZZ-704_take-it-to-the-limit --> - + - + - - + + - - + + - + + + + - - + - - + + + feature/ABC-66_make-bar - - - - + + + + feature/ZZ-704_take-it-to-the-limit - - + - - + + + feature/XYZ-12_fix-foo - - - - - - + + + + + + develop