From c754034543d9aab7d97b9d3e925bcfc892574d62 Mon Sep 17 00:00:00 2001 From: Nicolas Carlo Date: Fri, 6 Jan 2017 09:56:42 +0100 Subject: [PATCH 1/7] Code reformat and typos correction --- examples/gitflowsupport.html | 41 +++-- examples/gitflowsupport.js | 319 +++++++++++++++++++++++++---------- 2 files changed, 256 insertions(+), 104 deletions(-) diff --git a/examples/gitflowsupport.html b/examples/gitflowsupport.html index ed63e9a9..da21d5f6 100644 --- a/examples/gitflowsupport.html +++ b/examples/gitflowsupport.html @@ -1,23 +1,30 @@ - - - git flow with support - - - + + + Git Flow with support + + + + + + +
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sint, ducimus, qui fuga corporis veritatis doloribus iure nulla + optio dolores maiores dolorum ullam alias cum libero obcaecati cupiditate sit illo aperiam possimus voluptatum similique + neque explicabo quibusdam aspernatur dolorem. Quod, corrupti magni explicabo nam sequi nesciunt accusamus aliquam dolore! + Cumque, quam fugiat ab veritatis. Quia, maxime quas perferendis cupiditate explicabo at atque iusto accusamus. Nesciunt + veniam quidem nemo doloribus! Dolore, cupiditate, adipisci, voluptate quam nihil ipsa placeat dolor possimus minus quas + nostrum eaque in dicta autem eligendi rerum facilis nesciunt sunt doloremque suscipit enim iure vitae eius voluptates + tempora tenetur hic.
+ + + diff --git a/examples/gitflowsupport.js b/examples/gitflowsupport.js index a76ba651..c6035b33 100644 --- a/examples/gitflowsupport.js +++ b/examples/gitflowsupport.js @@ -1,36 +1,36 @@ var graphConfig = new GitGraph.Template({ - branch: { - color: "#000000", - lineWidth: 3, - spacingX: 60, - mergeStyle: "straight", - showLabel: true, // display branch names on graph - labelFont: "normal 10pt Arial", - labelRotation: 0 + branch: { + color: "#000000", + lineWidth: 3, + spacingX: 60, + mergeStyle: "straight", + showLabel: true, // display branch names on graph + labelFont: "normal 10pt Arial", + labelRotation: 0 + }, + commit: { + spacingY: -30, + dot: { + size: 8, + strokeColor: "#000000", + strokeWidth: 4 }, - commit: { - spacingY: -30, - dot: { - size: 8, - strokeColor: "#000000", - strokeWidth: 4 - }, - tag: { - font: "normal 10pt Arial", - color: "yellow" - }, - message: { - color: "black", - font: "normal 12pt Arial", - displayAuthor: false, - displayBranch: false, - displayHash: false, - } + tag: { + font: "normal 10pt Arial", + color: "yellow" }, - arrow: { - size: 8, - offset: 3 + message: { + color: "black", + font: "normal 12pt Arial", + displayAuthor: false, + displayBranch: false, + displayHash: false, } + }, + arrow: { + size: 8, + offset: 3 + } }); var config = { @@ -39,18 +39,18 @@ var config = { orientation: "horizontal" }; -var bugfixCommit = { - messageAuthorDisplay:false, - messageBranchDisplay:false, - messageHashDisplay:false, - message:"Bug fix commit(s)" +var bugFixCommit = { + messageAuthorDisplay: false, + messageBranchDisplay: false, + messageHashDisplay: false, + message: "Bug fix commit(s)" }; -var stablizationCommit = { - messageAuthorDisplay:false, - messageBranchDisplay:false, - messageHashDisplay:false, - message:"Release stablization commit(s)" +var stabilizationCommit = { + messageAuthorDisplay: false, + messageBranchDisplay: false, + messageHashDisplay: false, + message: "Release stabilization commit(s)" }; // You can manually fix columns to control the display. @@ -62,76 +62,221 @@ var masterCol = 4; var gitgraph = new GitGraph(config); -var master = gitgraph.branch({name:"master", column:masterCol}); +var master = gitgraph.branch({ + name: "master", + column: masterCol +}); master.commit("Initial commit"); -var develop = gitgraph.branch({parentBranch:master, name: "develop", column:developCol}); -master.commit({messageDisplay:false}); -develop.commit({messageDisplay:false}); +var develop = gitgraph.branch({ + parentBranch: master, + name: "develop", + column: developCol +}); +master.commit({ + messageDisplay: false +}); +develop.commit({ + messageDisplay: false +}); -var feature1 = gitgraph.branch({parentBranch:develop, name:"feature/1", column:featureCol}); -feature1.commit("A feature to go into v1.0.0").commit({messageDisplay:false}); +var feature1 = gitgraph.branch({ + parentBranch: develop, + name: "feature/1", + column: featureCol +}); +feature1.commit("A feature to go into v1.0.0").commit({ + messageDisplay: false +}); feature1.merge(develop); -var feature2 = gitgraph.branch({parentBranch:develop, name:"feature/2", column:featureCol}); -feature2.commit("Another feature to go into v1.0.0").commit({messageDisplay:false}); +var feature2 = gitgraph.branch({ + parentBranch: develop, + name: "feature/2", + column: featureCol +}); +feature2.commit("Another feature to go into v1.0.0").commit({ + messageDisplay: false +}); feature2.merge(develop); -var release_100 = gitgraph.branch({parentBranch: develop, name: "release/v1.0.0", column:releaseCol}); -release_100.commit({message:"Start v1.0.0-rc Release Candidate builds",tag:"v1.0.0-rc",tagColor:'gray'}); -develop.commit({messageDisplay:false}); -release_100.commit(stablizationCommit); -release_100.merge(develop).merge(master, {dotStrokeWidth: 10, message: "Release v1.0.0 tagged",tag:"v1.0.0"}); +var release_100 = gitgraph.branch({ + parentBranch: develop, + name: "release/v1.0.0", + column: releaseCol +}); +release_100.commit({ + message: "Start v1.0.0-rc Release Candidate builds", + tag: "v1.0.0-rc", + tagColor: 'gray' +}); +develop.commit({ + messageDisplay: false +}); +release_100.commit(stabilizationCommit); +release_100.merge(develop).merge(master, { + dotStrokeWidth: 10, + message: "Release v1.0.0 tagged", + tag: "v1.0.0" +}); -var support_10x = gitgraph.branch({parentBranch: master, name: "support/v1.0.x", column:supportCol}); -support_10x.commit({message:"Start v1.0.1-rc Release Candidate builds",tag:"v1.0.1-rc",tagColor:'gray'}).commit(bugfixCommit); +var support_10x = gitgraph.branch({ + parentBranch: master, + name: "support/v1.0.x", + column: supportCol +}); +support_10x.commit({ + message: "Start v1.0.1-rc Release Candidate builds", + tag: "v1.0.1-rc", + tagColor: 'gray' +}).commit(bugFixCommit); -var feature3 = gitgraph.branch({parentBranch:develop, name:"feature/3", column:featureCol}); -develop.commit({messageDisplay:false}); -feature3.commit("A feature to go into v1.1.0").commit({messageDisplay:false}); +var feature3 = gitgraph.branch({ + parentBranch: develop, + name: "feature/3", + column: featureCol +}); +develop.commit({ + messageDisplay: false +}); +feature3.commit("A feature to go into v1.1.0").commit({ + messageDisplay: false +}); feature3.merge(develop); -support_10x.commit({dotStrokeWidth: 10, message: "Release v1.0.1 tagged",tag:"v1.0.1"}).merge(develop); +support_10x.commit({ + dotStrokeWidth: 10, + message: "Release v1.0.1 tagged", + tag: "v1.0.1" +}).merge(develop); -develop.commit({messageDisplay:false}); -support_10x.commit({message:"Start v1.0.2-rc Release Candidate builds",tag:"v1.0.2-rc",tagColor:'gray'}) -support_10x.commit(bugfixCommit).commit({dotStrokeWidth: 10, message: "Release v1.0.2 tagged",tag:'v1.0.2'}); +develop.commit({ + messageDisplay: false +}); +support_10x.commit({ + message: "Start v1.0.2-rc Release Candidate builds", + tag: "v1.0.2-rc", + tagColor: 'gray' +}) +support_10x.commit(bugFixCommit).commit({ + dotStrokeWidth: 10, + message: "Release v1.0.2 tagged", + tag: 'v1.0.2' +}); support_10x.merge(develop); -develop.commit({messageDisplay:false}); +develop.commit({ + messageDisplay: false +}); -var release_110 = gitgraph.branch({parentBranch: develop, name: "release/v1.1.0", column:releaseCol}); -release_110.commit({message:"Start v1.1.0-rc Release Candidate builds",tag:"v1.1.0-rc",tagColor:'gray'}) -release_110.commit(stablizationCommit); -release_110.merge(develop).merge(master, {dotStrokeWidth: 10, message: "Release v1.1.0 tagged",tag:"v1.1.0"}); +var release_110 = gitgraph.branch({ + parentBranch: develop, + name: "release/v1.1.0", + column: releaseCol +}); +release_110.commit({ + message: "Start v1.1.0-rc Release Candidate builds", + tag: "v1.1.0-rc", + tagColor: 'gray' +}) +release_110.commit(stabilizationCommit); +release_110.merge(develop).merge(master, { + dotStrokeWidth: 10, + message: "Release v1.1.0 tagged", + tag: "v1.1.0" +}); -var support_11x = gitgraph.branch({parentBranch: master, name: "support/v1.1.x", column:supportCol}); -support_11x.commit({message:"Start v1.1.1-rc Release Candidate builds",tag:"v1.1.1-rc",tagColor:'gray'}) -support_11x.commit(bugfixCommit).commit({dotStrokeWidth: 10, message: "Release v1.1.1 tagged",tag:"v1.1.1"}); +var support_11x = gitgraph.branch({ + parentBranch: master, + name: "support/v1.1.x", + column: supportCol +}); +support_11x.commit({ + message: "Start v1.1.1-rc Release Candidate builds", + tag: "v1.1.1-rc", + tagColor: 'gray' +}) +support_11x.commit(bugFixCommit).commit({ + dotStrokeWidth: 10, + message: "Release v1.1.1 tagged", + tag: "v1.1.1" +}); support_11x.merge(develop); -develop.commit({messageDisplay:false}); +develop.commit({ + messageDisplay: false +}); -var feature4 = gitgraph.branch({parentBranch:develop, name:"feature/4", column:featureCol}); -develop.commit({messageDisplay:false}); -feature4.commit("A feature to go into v1.2.0").commit({messageDisplay:false}); +var feature4 = gitgraph.branch({ + parentBranch: develop, + name: "feature/4", + column: featureCol +}); +develop.commit({ + messageDisplay: false +}); +feature4.commit("A feature to go into v1.2.0").commit({ + messageDisplay: false +}); feature4.merge(develop); -support_11x.commit({message:"Start v1.1.2-rc Release Candidate builds",tag:"v1.1.2-rc",tagColor:'gray'}) -support_11x.commit(bugfixCommit).commit({dotStrokeWidth: 10, message: "Release v1.1.2",tag:"v1.1.2"}); +support_11x.commit({ + message: "Start v1.1.2-rc Release Candidate builds", + tag: "v1.1.2-rc", + tagColor: 'gray' +}) +support_11x.commit(bugFixCommit).commit({ + dotStrokeWidth: 10, + message: "Release v1.1.2", + tag: "v1.1.2" +}); support_11x.merge(develop); -develop.commit({messageDisplay:false}); +develop.commit({ + messageDisplay: false +}); -var feature5 = gitgraph.branch({parentBranch:develop, name:"feature/5", column:featureCol}); -develop.commit({messageDisplay:false}); -feature5.commit("Another feature to go into v1.2.0").commit({messageDisplay:false}); +var feature5 = gitgraph.branch({ + parentBranch: develop, + name: "feature/5", + column: featureCol +}); +develop.commit({ + messageDisplay: false +}); +feature5.commit("Another feature to go into v1.2.0").commit({ + messageDisplay: false +}); feature5.merge(develop); -support_11x.commit({message:"Start v1.1.3-rc Release Candidate builds",tag:"v1.1.3-rc",tagColor:'gray'}) -support_11x.commit(bugfixCommit).commit({dotStrokeWidth: 10, message: "Release v1.1.3 tagged",tag:"v1.1.3"}); +support_11x.commit({ + message: "Start v1.1.3-rc Release Candidate builds", + tag: "v1.1.3-rc", + tagColor: 'gray' +}) +support_11x.commit(bugFixCommit).commit({ + dotStrokeWidth: 10, + message: "Release v1.1.3 tagged", + tag: "v1.1.3" +}); support_11x.merge(develop); -develop.commit({messageDisplay:false}); +develop.commit({ + messageDisplay: false +}); -var release_120 = gitgraph.branch({parentBranch: develop, name: "release/v1.2.0", column:releaseCol}); -release_120.commit({message:"Start v1.2.0-rc Release Candidate builds",tag:"v1.2.0-rc",tagColor:'gray'}) -release_120.commit(stablizationCommit); -release_120.merge(develop).merge(master, {dotStrokeWidth: 10, message: "Release v1.2.0 tagged",tag:"v1.2.0"}); -develop.commit({messageDisplay:false}); +var release_120 = gitgraph.branch({ + parentBranch: develop, + name: "release/v1.2.0", + column: releaseCol +}); +release_120.commit({ + message: "Start v1.2.0-rc Release Candidate builds", + tag: "v1.2.0-rc", + tagColor: 'gray' +}) +release_120.commit(stabilizationCommit); +release_120.merge(develop).merge(master, { + dotStrokeWidth: 10, + message: "Release v1.2.0 tagged", + tag: "v1.2.0" +}); +develop.commit({ + messageDisplay: false +}); From 2fe7e030db4292a0225a0e3ab3b68d0719cc69fb Mon Sep 17 00:00:00 2001 From: Nicolas Carlo Date: Fri, 6 Jan 2017 19:12:33 +0100 Subject: [PATCH 2/7] Handle merges when branch is already up-to-date --- src/gitgraph.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gitgraph.js b/src/gitgraph.js index 10eb1b8e..66ccb8a4 100644 --- a/src/gitgraph.js +++ b/src/gitgraph.js @@ -837,6 +837,12 @@ return this; } + var firstBranchCommit = this.commits[0]; + if (!firstBranchCommit) { + console.log(this.name + " is already up-to-date with " + targetBranch.name); + return this; + } + // Merge commit var defaultMessage = "Merge branch `" + this.name + "` into `" + targetBranch.name + "`"; if (typeof commitOptions !== "object") { From 45edd8d65a972a454cbdfcf6ce2374dedd255e31 Mon Sep 17 00:00:00 2001 From: Nicolas Carlo Date: Fri, 6 Jan 2017 19:12:54 +0100 Subject: [PATCH 3/7] Fix fast-forward checks --- src/gitgraph.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gitgraph.js b/src/gitgraph.js index 66ccb8a4..ad9fdb69 100644 --- a/src/gitgraph.js +++ b/src/gitgraph.js @@ -855,9 +855,9 @@ commitOptions.type = "mergeCommit"; commitOptions.parentCommit = _getParentCommitFromBranch(this); - var branchParentCommit = this.commits[0].parentCommit; - var parentBranchLastCommit = _getLast(targetBranch.commits); - var isFastForwardPossible = (branchParentCommit.sha1 === parentBranchLastCommit.sha1); + var branchParentCommit = firstBranchCommit.parentCommit; + var targetBranchParentCommit = _getParentCommitFromBranch(targetBranch); + var isFastForwardPossible = (branchParentCommit && branchParentCommit.sha1 === targetBranchParentCommit.sha1); if (commitOptions.fastForward && isFastForwardPossible) { var isGraphHorizontal  = _isHorizontal(this.parent); this.color = targetBranch.color; From 6212e6ffacaf45eafaed2b9440228a3e9ad8b32c Mon Sep 17 00:00:00 2001 From: Nicolas Carlo Date: Fri, 6 Jan 2017 23:50:19 +0100 Subject: [PATCH 4/7] Refactor useless ternary --- src/gitgraph.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gitgraph.js b/src/gitgraph.js index ad9fdb69..ed6d5847 100644 --- a/src/gitgraph.js +++ b/src/gitgraph.js @@ -712,8 +712,7 @@ var isFirstBranch = !(options.parentCommit instanceof Commit); var isPathBeginning = this.path.length === 0; - options.showLabel = (isPathBeginning && this.showLabel) ? true : false; - + options.showLabel = (isPathBeginning && this.showLabel); if (options.showLabel) { options.x -= this.template.commit.spacingX; options.y -= this.template.commit.spacingY; From 2a305c84a228ab88e31524167aec49e4ffb10955 Mon Sep 17 00:00:00 2001 From: Nicolas Carlo Date: Mon, 9 Jan 2017 23:19:20 +0100 Subject: [PATCH 5/7] Handle empty parent branch --- src/gitgraph.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gitgraph.js b/src/gitgraph.js index ed6d5847..7eb4cbf1 100644 --- a/src/gitgraph.js +++ b/src/gitgraph.js @@ -521,7 +521,7 @@ // Add start point if (this.parentBranch) { - if (this.parentCommit === _getParentCommitFromBranch(this.parentBranch)) { + if (this.parentCommit === _getParentCommitFromBranch(this.parentBranch) && this.commits.length > 0) { this.startPoint = { x: this.parentBranch.offsetX - this.parent.commitOffsetX + this.template.commit.spacingX, y: this.parentBranch.offsetY - this.parent.commitOffsetY + this.template.commit.spacingY, From 7752479dfd430849162117c678ba1ed0b9adce5f Mon Sep 17 00:00:00 2001 From: Nicolas Carlo Date: Mon, 9 Jan 2017 23:30:27 +0100 Subject: [PATCH 6/7] Fix failing tests --- src/gitgraph.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gitgraph.js b/src/gitgraph.js index 7eb4cbf1..8a8babd0 100644 --- a/src/gitgraph.js +++ b/src/gitgraph.js @@ -520,7 +520,7 @@ this.offsetY = this.column * this.spacingY; // Add start point - if (this.parentBranch) { + if (this.parentBranch && this.parentCommit) { if (this.parentCommit === _getParentCommitFromBranch(this.parentBranch) && this.commits.length > 0) { this.startPoint = { x: this.parentBranch.offsetX - this.parent.commitOffsetX + this.template.commit.spacingX, From bc6651686759cda357caa3bdfd82a1fa03cebf2b Mon Sep 17 00:00:00 2001 From: Nicolas Carlo Date: Mon, 9 Jan 2017 23:31:56 +0100 Subject: [PATCH 7/7] Bump version and compile --- bower.json | 2 +- build/gitgraph.js | 21 +++++++++++++-------- build/gitgraph.min.js | 4 ++-- docs/Branch.html | 14 +++++++------- docs/Commit.html | 8 ++++---- docs/GitGraph.html | 2 +- docs/Tag.html | 4 ++-- docs/Template.html | 6 +++--- docs/gitgraph.js.html | 21 +++++++++++++-------- docs/global.html | 28 ++++++++++++++-------------- docs/index.html | 2 +- package.json | 19 ++++++++----------- 12 files changed, 69 insertions(+), 62 deletions(-) diff --git a/bower.json b/bower.json index 2124cc6c..4b90f2c4 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "gitgraph.js", - "version": "1.8.0", + "version": "1.8.1", "main": ["./build/gitgraph.js", "./build/gitgraph.css"], "ignore": [ "**/.*" diff --git a/build/gitgraph.js b/build/gitgraph.js index 2f312ac5..a2856956 100644 --- a/build/gitgraph.js +++ b/build/gitgraph.js @@ -1,5 +1,5 @@ /* ========================================================== - * GitGraph v1.8.0 + * GitGraph v1.8.1 * https://github.com/nicoespeon/gitgraph.js * ========================================================== * Copyright (c) 2017 Nicolas CARLO (@nicoespeon) ٩(^‿^)۶ @@ -530,8 +530,8 @@ this.offsetY = this.column * this.spacingY; // Add start point - if (this.parentBranch) { - if (this.parentCommit === _getParentCommitFromBranch(this.parentBranch)) { + if (this.parentBranch && this.parentCommit) { + if (this.parentCommit === _getParentCommitFromBranch(this.parentBranch) && this.commits.length > 0) { this.startPoint = { x: this.parentBranch.offsetX - this.parent.commitOffsetX + this.template.commit.spacingX, y: this.parentBranch.offsetY - this.parent.commitOffsetY + this.template.commit.spacingY, @@ -722,8 +722,7 @@ var isFirstBranch = !(options.parentCommit instanceof Commit); var isPathBeginning = this.path.length === 0; - options.showLabel = (isPathBeginning && this.showLabel) ? true : false; - + options.showLabel = (isPathBeginning && this.showLabel); if (options.showLabel) { options.x -= this.template.commit.spacingX; options.y -= this.template.commit.spacingY; @@ -847,6 +846,12 @@ return this; } + var firstBranchCommit = this.commits[0]; + if (!firstBranchCommit) { + console.log(this.name + " is already up-to-date with " + targetBranch.name); + return this; + } + // Merge commit var defaultMessage = "Merge branch `" + this.name + "` into `" + targetBranch.name + "`"; if (typeof commitOptions !== "object") { @@ -859,9 +864,9 @@ commitOptions.type = "mergeCommit"; commitOptions.parentCommit = _getParentCommitFromBranch(this); - var branchParentCommit = this.commits[0].parentCommit; - var parentBranchLastCommit = _getLast(targetBranch.commits); - var isFastForwardPossible = (branchParentCommit.sha1 === parentBranchLastCommit.sha1); + var branchParentCommit = firstBranchCommit.parentCommit; + var targetBranchParentCommit = _getParentCommitFromBranch(targetBranch); + var isFastForwardPossible = (branchParentCommit && branchParentCommit.sha1 === targetBranchParentCommit.sha1); if (commitOptions.fastForward && isFastForwardPossible) { var isGraphHorizontal  = _isHorizontal(this.parent); this.color = targetBranch.color; diff --git a/build/gitgraph.min.js b/build/gitgraph.min.js index 12c8f96e..8d638aa6 100644 --- a/build/gitgraph.min.js +++ b/build/gitgraph.min.js @@ -1,5 +1,5 @@ /* ========================================================== - * GitGraph v1.8.0 + * GitGraph v1.8.1 * https://github.com/nicoespeon/gitgraph.js * ========================================================== * Copyright (c) 2017 Nicolas CARLO (@nicoespeon) ٩(^‿^)۶ @@ -7,4 +7,4 @@ * * GitGraph.js may be freely distributed under the MIT Licence * ========================================================== */ -!function(){"use strict";function a(a){switch(a=q(a)?a:{},this.elementId="string"==typeof a.elementId?a.elementId:"gitGraph",this.author="string"==typeof a.author?a.author:"Sergio Flores ",this.reverseArrow=k(a.reverseArrow,!1),this.template="string"==typeof a.template||q(a.template)?this.newTemplate(a.template):a.template instanceof e?a.template:this.newTemplate("metro"),this.mode=a.mode||null,"compact"===this.mode&&(this.template.commit.message.display=!1),a.orientation){case"vertical-reverse":this.template.commit.spacingY*=-1,this.orientation="vertical-reverse",this.template.branch.labelRotation=r(a,"template.branch.labelRotation")?0:a.template.branch.labelRotation,this.template.commit.tag.spacingY*=-1;break;case"horizontal":this.template.commit.message.display=!1,this.template.commit.spacingX=this.template.commit.spacingY,this.template.branch.spacingY=this.template.branch.spacingX,this.template.commit.spacingY=0,this.template.branch.spacingX=0,this.orientation="horizontal",this.template.branch.labelRotation=r(a,"template.branch.labelRotation")?-90:a.template.branch.labelRotation,this.template.commit.tag.spacingX=-this.template.commit.spacingX,this.template.commit.tag.spacingY=this.template.branch.spacingY;break;case"horizontal-reverse":this.template.commit.message.display=!1,this.template.commit.spacingX=-this.template.commit.spacingY,this.template.branch.spacingY=this.template.branch.spacingX,this.template.commit.spacingY=0,this.template.branch.spacingX=0,this.orientation="horizontal-reverse",this.template.branch.labelRotation=r(a,"template.branch.labelRotation")?90:a.template.branch.labelRotation,this.template.commit.tag.spacingX=-this.template.commit.spacingY,this.template.commit.tag.spacingY=this.template.branch.spacingY;break;default:this.orientation="vertical",this.template.branch.labelRotation=r(a,"template.branch.labelRotation")?0:a.template.branch.labelRotation}this.marginX=this.template.branch.spacingX+2*this.template.commit.dot.size,this.marginY=this.template.branch.spacingY+2*this.template.commit.dot.size,this.offsetX=0,this.offsetY=0,this.canvas=document.getElementById(this.elementId)||a.canvas,this.context=this.canvas.getContext("2d"),this.context.textBaseline="center",this.tooltip=document.createElement("div"),this.tooltip.className="gitgraph-tooltip",this.tooltip.style.position="fixed",this.tooltip.style.display="none",document.body.appendChild(this.tooltip),this.HEAD=null,this.branches=[],this.commits=[],this.columnMax=0,this.commitOffsetX=a.initCommitOffsetX||0,this.commitOffsetY=a.initCommitOffsetY||0,this.mouseMoveOptions={handleEvent:this.hover,gitgraph:this},this.canvas.addEventListener("mousemove",this.mouseMoveOptions,!1),this.mouseDownOptions={handleEvent:this.click,gitgraph:this},this.canvas.addEventListener("mousedown",this.mouseDownOptions,!1),window.onresize=this.render.bind(this)}function b(b){if(b.parent instanceof a!=!1){if(b=q(b)?b:{},this.parent=b.parent,b.parentCommit&&b.parentBranch){if(b.parentCommit.branch!==b.parentBranch)return;this.parentCommit=b.parentCommit,this.parentBranch=b.parentBranch}else b.parentCommit?(this.parentCommit=b.parentCommit,this.parentBranch=b.parentCommit.branch):b.parentBranch?(this.parentCommit=h(b.parentBranch),this.parentBranch=b.parentBranch):(this.parentCommit=null,this.parentBranch=null);this.name="string"==typeof b.name?b.name:"no-name",this.commitDefaultOptions=q(b.commitDefaultOptions)?b.commitDefaultOptions:{},this.context=this.parent.context,this.template=this.parent.template,this.lineWidth=b.lineWidth||this.template.branch.lineWidth,this.lineDash=b.lineDash||this.template.branch.lineDash,this.showLabel=k(b.showLabel,this.template.branch.showLabel),this.spacingX=this.template.branch.spacingX,this.spacingY=this.template.branch.spacingY,this.size=0,this.height=0,this.width=0,this.commits=[],this.path=[],"number"==typeof b.column?this.column=b.column:(this.column=0,this.calculColumn()),this.parent.columnMax=this.column>this.parent.columnMax?this.column:this.parent.columnMax,this.offsetX=this.column*this.spacingX,this.offsetY=this.column*this.spacingY,this.startPoint=this.parentBranch?this.parentCommit===h(this.parentBranch)?{x:this.parentBranch.offsetX-this.parent.commitOffsetX+this.template.commit.spacingX,y:this.parentBranch.offsetY-this.parent.commitOffsetY+this.template.commit.spacingY,type:"start"}:{x:this.parentCommit.x,y:this.parentCommit.y,type:"start"}:null;var c=this.column%this.template.colors.length;this.color=b.color||this.template.branch.color||this.template.colors[c],this.checkout()}}function c(b){b.parent instanceof a!=!1&&(b=q(b)?b:{},this.parent=b.parent,this.template=this.parent.template,this.context=this.parent.context,this.branch=b.branch,this.author=b.author||this.parent.author,this.date=b.date||(new Date).toUTCString(),this.detail=b.detail||null,this.sha1=b.sha1||Math.random(100).toString(16).substring(3,10),this.message=b.message||"He doesn't like George Michael! Boooo!",this.arrowDisplay=b.arrowDisplay,this.messageDisplay=k(b.messageDisplay,this.template.commit.message.display),this.messageAuthorDisplay=k(b.messageAuthorDisplay,this.template.commit.message.displayAuthor),this.messageBranchDisplay=k(b.messageBranchDisplay,this.template.commit.message.displayBranch),this.messageHashDisplay=k(b.messageHashDisplay,this.template.commit.message.displayHash),this.messageColor=b.messageColor||b.color,this.messageFont=b.messageFont||this.template.commit.message.font,this.dotColor=b.dotColor||b.color,this.dotSize=b.dotSize||this.template.commit.dot.size,this.dotStrokeWidth=b.dotStrokeWidth||this.template.commit.dot.strokeWidth,this.dotStrokeColor=b.dotStrokeColor||this.template.commit.dot.strokeColor||b.color,this.type=b.type||null,this.tooltipDisplay=k(b.tooltipDisplay,!0),this.onClick=b.onClick||null,this.representedObject=b.representedObject||null,this.parentCommit=b.parentCommit,this.x=b.x,this.y=b.y,this.showLabel=b.showLabel,this.labelColor=b.labelColor||b.color,this.labelFont=b.labelFont||this.template.branch.labelFont,g(this,b),this.parent.commits.push(this))}function d(a,b){if(!q(a))throw new Error("You can't tag a commit that doesn't exist");b=q(b)?b:{},this.color=b.color||a.color,this.font=b.font||a.template.commit.tag.font;var c=a.context.font;a.context.font=this.font;var d=a.context.measureText(a.tag).width;this.width=Math.max(a.template.commit.tag.spacingX,d),a.parent.tagNum++;var e=0,f=0;return p(a.parent)?(e=a.x-a.dotSize/2,f=(a.parent.columnMax+1)*a.template.commit.tag.spacingY-a.template.commit.tag.spacingY/2+a.parent.tagNum%2*j(this.font)*1.5):(e=(a.parent.columnMax+1)*a.template.commit.tag.spacingX-a.template.commit.tag.spacingX/2+d/2,f=a.y-a.dotSize/2),l(a.context,e,f,a.tag,this.color,this.font,0,a.displayTagBox),a.context.font=c,this}function e(a){a=q(a)?a:{},a.branch=a.branch||{},a.arrow=a.arrow||{},a.commit=a.commit||{},a.commit.dot=a.commit.dot||{},a.commit.tag=a.commit.tag||{},a.commit.message=a.commit.message||{},this.colors=a.colors||["#6963FF","#47E8D4","#6BDB52","#E84BA5","#FFA657"],this.branch={},this.branch.color=a.branch.color||null,this.branch.lineWidth=a.branch.lineWidth||2,this.branch.lineDash=a.branch.lineDash||[],this.branch.showLabel=a.branch.showLabel||!1,this.branch.labelColor=a.branch.labelColor||null,this.branch.labelFont=a.branch.labelFont||"normal 8pt Calibri",this.branch.labelRotation=void 0!==a.branch.labelRotation?a.branch.labelRotation:null,this.branch.mergeStyle=a.branch.mergeStyle||"bezier",this.branch.spacingX="number"==typeof a.branch.spacingX?a.branch.spacingX:20,this.branch.spacingY=a.branch.spacingY||0,this.arrow={},this.arrow.size=a.arrow.size||null,this.arrow.color=a.arrow.color||null,this.arrow.active="number"==typeof this.arrow.size,this.arrow.offset=a.arrow.offset||2,this.commit={},this.commit.spacingX=a.commit.spacingX||0,this.commit.spacingY="number"==typeof a.commit.spacingY?a.commit.spacingY:25,this.commit.widthExtension="number"==typeof a.commit.widthExtension?a.commit.widthExtension:0,this.commit.tooltipHTMLFormatter=a.commit.tooltipHTMLFormatter||null,this.commit.shouldDisplayTooltipsInCompactMode=k(a.commit.shouldDisplayTooltipsInCompactMode,!0),this.commit.color=a.commit.color||null,this.commit.dot={},this.commit.dot.color=a.commit.dot.color||null,this.commit.dot.size=a.commit.dot.size||3,this.commit.dot.strokeWidth=a.commit.dot.strokeWidth||null,this.commit.dot.strokeColor=a.commit.dot.strokeColor||null,this.commit.tag={},this.commit.tag.color=a.commit.tag.color||this.commit.dot.color,this.commit.tag.font=a.commit.tag.font||a.commit.message.font||"normal 10pt Calibri",this.commit.tag.spacingX=this.branch.spacingX,this.commit.tag.spacingY=this.commit.spacingY,this.commit.message={},this.commit.message.display=k(a.commit.message.display,!0),this.commit.message.displayAuthor=k(a.commit.message.displayAuthor,!0),this.commit.message.displayBranch=k(a.commit.message.displayBranch,!0),this.commit.message.displayHash=k(a.commit.message.displayHash,!0),this.commit.message.color=a.commit.message.color||null,this.commit.message.font=a.commit.message.font||"normal 12pt Calibri"}function f(a){return a.slice(-1)[0]}function g(a,b){a.tag=b.tag||null,a.tagColor=b.tagColor||a.messageColor,a.tagFont=b.tagFont||a.template.commit.tag.font,a.displayTagBox=k(b.displayTagBox,!0)}function h(a){return f(a.commits)?f(a.commits):a.parentBranch?h(a.parentBranch):null}function i(a){return JSON.parse(JSON.stringify(a))}function j(a){var b=document.getElementsByTagName("body")[0],c=document.createElement("div"),d=document.createTextNode("Mg");c.appendChild(d),c.setAttribute("style","font: "+a+";"),b.appendChild(c);var e=c.offsetHeight;return b.removeChild(c),e}function k(a,b){return"boolean"==typeof a?a:b}function l(a,b,c,d,e,f,g,h){a.save(),a.translate(b,c),a.rotate(g*(Math.PI/180)),a.textAlign="center",a.font=f;var i=a.measureText(d).width,k=j(f);h?(a.beginPath(),a.rect(-(i/2)-4,-(k/2)+2,i+8,k+2),a.fillStyle=e,a.fill(),a.lineWidth=2,a.strokeStyle="black",a.stroke(),a.fillStyle="black"):a.fillStyle=e,a.fillText(d,0,k/2),a.restore()}function m(a,b,c){var d;document.createEvent?(d=document.createEvent("HTMLEvents"),d.initEvent(b,!0,!0)):(d=document.createEventObject(),d.eventType=b),d.eventName=b,d.data=c||{},document.createEvent?a.dispatchEvent(d):a.fireEvent("on"+d.eventType,d)}function n(a){var b,c;return c=1,window.devicePixelRatio&&(b=a.webkitBackingStorePixelRatio||a.mozBackingStorePixelRatio||a.msBackingStorePixelRatio||a.oBackingStorePixelRatio||a.backingStorePixelRatio||1,c*=window.devicePixelRatio/b),c}function o(a){return"vertical"===a.orientation||"vertical-reverse"===a.orientation}function p(a){return"horizontal"===a.orientation||"horizontal-reverse"===a.orientation}function q(a){return"object"==typeof a}function r(a,b){return!b.split(".").every(function(b){return"object"==typeof a&&null!==a&&b in a?(a=a[b],!0):!1})}a.prototype.dispose=function(){this.canvas.removeEventListener("mousemove",this.mouseMoveOptions,!1),this.canvas.removeEventListener("mousedown",this.mouseDownOptions,!1)},a.prototype.branch=function(a){if("string"==typeof a){var c=a;a={},a.name=c}a=q(a)?a:{},a.parent=this,a.parentBranch=a.parentBranch||this.HEAD;var d=new b(a);return this.branches.push(d),d},a.prototype.orphanBranch=function(a){if("string"==typeof a){var c=a;a={},a.name=c}a=q(a)?a:{},a.parent=this;var d=new b(a);return this.branches.push(d),d},a.prototype.commit=function(a){return this.HEAD.commit(a),this},a.prototype.tag=function(a){return this.HEAD.tag(a),this},a.prototype.newTemplate=function(a){return"string"==typeof a?(new e).get(a):new e(a)},a.prototype.render=function(){this.scalingFactor=n(this.context);var a={x:Math.abs((this.columnMax+1)*this.template.branch.spacingX)+Math.abs(this.commitOffsetX)+2*this.marginX,y:Math.abs((this.columnMax+1)*this.template.branch.spacingY)+Math.abs(this.commitOffsetY)+2*this.marginY};this.template.commit.message.display&&(a.x+=800),a.x+=this.template.commit.widthExtension,this.canvas.style.width=a.x+"px",this.canvas.style.height=a.y+"px",this.canvas.width=a.x*this.scalingFactor,this.canvas.height=a.y*this.scalingFactor,this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.context.translate(this.marginX,this.marginY),this.template.commit.spacingY>0&&(this.context.translate(0,this.canvas.height-2*this.marginY),this.offsetY=this.canvas.height-2*this.marginY),this.template.commit.spacingX>0&&(this.context.translate(this.canvas.width-2*this.marginX,0),this.offsetX=this.canvas.width-2*this.marginX),this.context.scale(this.scalingFactor,this.scalingFactor);for(var b,c=this.branches.length-1;b=this.branches[c];c--)b.render();this.tagNum=0;for(var d,e=0;d=this.commits[e];e++)d.render();m(this.canvas,"graph:render",{id:this.elementId})},a.prototype.applyCommits=function(a,b){function c(a){var b=document.getElementById(a),c=b.getBoundingClientRect();return{top:c.top+document.body.scrollTop,left:c.left+document.body.scrollLeft}}for(var d,e=a.offsetX||a.pageX-c(this.elementId).left,f=a.offsetY||a.pageY-c(this.elementId).top,g=0;d=this.commits[g];g++){var h=d.x+(this.offsetX+this.marginX)/this.scalingFactor-e,i=d.y+(this.offsetY+this.marginY)/this.scalingFactor-f,j=Math.sqrt(Math.pow(h,2)+Math.pow(i,2)),k=j0){this.pushPath({x:this.startPoint.x-this.parentBranch.offsetX+this.offsetX-this.template.commit.spacingX,y:this.startPoint.y-this.parentBranch.offsetY+this.offsetY-this.template.commit.spacingY,type:"join"});var r=i(this.startPoint);r.type="join",this.parentBranch.pushPath(r)}}else o&&(q.type="start");return this.pushPath(q),this.parent.commitOffsetX+=this.template.commit.spacingX*(a.showLabel?2:1),this.parent.commitOffsetY+=this.template.commit.spacingY*(a.showLabel?2:1),null!==p.detail&&(p.detail.style.display="block",this.parent.commitOffsetY-=p.detail.clientHeight-40),this.parent.render(),this},b.prototype.tag=function(a){"string"==typeof a&&(a={tag:a}),a=q(a)?a:{};var b=f(this.commits);return q(b)&&(g(b,a),this.parent.render()),this},b.prototype.checkout=function(){this.parent.HEAD=this},b.prototype.delete=function(){this.isDeleted=!0},b.prototype.merge=function(a,c){var d=a||this.parent.HEAD;if(d instanceof b==!1||d===this)return this;var e="Merge branch `"+this.name+"` into `"+d.name+"`";if("object"!=typeof c){var g=c;c={},c.message="string"==typeof g?g:e}else c.message=c.message||e;c.type="mergeCommit",c.parentCommit=h(this);var j=this.commits[0].parentCommit,k=f(d.commits),l=j.sha1===k.sha1;if(c.fastForward&&l){var m=p(this.parent);if(this.color=d.color,m){var n=d.path[1].y;this.path.forEach(function(a){a.y=n})}else{var o=d.path[1].x;this.path.forEach(function(a){a.x=o})}this.commits.forEach(function(a){m?a.y=j.y:a.x=j.x,a.labelColor=j.labelColor,a.messageColor=j.messageColor,a.dotColor=j.dotColor,a.dotStrokeColor=j.dotStrokeColor})}else{d.commit(c);var q=f(d.commits),r={x:this.offsetX+this.template.commit.spacingX*(q.showLabel?3:2)-this.parent.commitOffsetX,y:this.offsetY+this.template.commit.spacingY*(q.showLabel?3:2)-this.parent.commitOffsetY,type:"join"};this.pushPath(i(r));var s={x:q.x,y:q.y,type:"end"};this.pushPath(s),r.type="start",this.pushPath(r)}return this.parent.render(),this.parent.HEAD=d,this},b.prototype.calculColumn=function(){for(var a,b=[],c=0;a=this.parent.branches[c];c++)a.isDeleted||(a.column in b||(b[a.column]=0),b[a.column]++);for(this.column=0;this.column in b&&0!==b[this.column];this.column++);},b.prototype.pushPath=function(a){var b=f(this.path);b?b.x===a.x&&b.y===a.y?"start"!==b.type&&"end"===a.type?b.type="end":"join"===a.type||this.path.push(a):"join"===a.type?(a.x-b.x)*this.template.commit.spacingX<0?this.path.push(a):(a.y-b.y)*this.template.commit.spacingY<0&&this.path.push(a):this.path.push(a):this.path.push(a)},c.prototype.render=function(){var a=this.template.commit.tag.spacingX,b=(this.parent.columnMax+1)*this.template.branch.spacingX+a;if(this.showLabel)if(p(this.parent)&&this.template.branch.labelRotation%180===0){var e=this.y-this.dotSize-j(this.labelFont);l(this.context,this.x,e,this.branch.name,this.labelColor,this.labelFont,this.template.branch.labelRotation,!0)}else l(this.context,this.x+this.template.commit.spacingX,this.y+this.template.commit.spacingY,this.branch.name,this.labelColor,this.labelFont,this.template.branch.labelRotation,!0);if(this.context.beginPath(),this.context.arc(this.x,this.y,this.dotSize,0,2*Math.PI,!1),this.context.fillStyle=this.dotColor,this.context.strokeStyle=this.dotStrokeColor,this.context.lineWidth=this.dotStrokeWidth,"number"==typeof this.dotStrokeWidth&&this.context.stroke(),this.context.fill(),this.context.closePath(),this.arrowDisplay&&this.parentCommit instanceof c&&this.arrow(),null!==this.tag){var f=new d(this,{color:this.tagColor,font:this.tagFont});b+=f.width-a}if(null!==this.detail&&(this.detail.style.left=this.parent.canvas.offsetLeft+b+this.x+30+"px",this.detail.style.top=this.parent.canvas.offsetTop+this.y+40+"px",this.detail.width=30),this.messageDisplay){var g=this.message;this.messageHashDisplay&&(g=this.sha1+" "+g),this.messageAuthorDisplay&&(g+=this.author?" - "+this.author:""),this.messageBranchDisplay&&(g=(this.branch.name?"["+this.branch.name+"] ":"")+g),this.context.font=this.messageFont,this.context.fillStyle=this.messageColor,this.context.fillText(g,b,this.y+this.dotSize/2)}},c.prototype.arrow=function(){function a(a,b){var c=d?-1:1;return Math.atan2(c*a,c*b)}var b=this.template.arrow.size,c=this.template.arrow.color||this.branch.color,d=this.parent.reverseArrow,e=a(this.parentCommit.y-this.y,this.parentCommit.x-this.x),f=this===this.branch.commits[0];if("mergeCommit"===this.type||f){var g=this.parentCommit.branch.column-this.branch.column,h=this.showLabel?2:1,i=this.template.branch.spacingX*g+this.template.commit.spacingX*h,j=(f||d)&&Math.abs(this.y-this.parentCommit.y)>Math.abs(this.template.commit.spacingY),k=this.x===this.parentCommit.x;o(this.parent)&&(j||k)&&(i=0);var l=this.template.branch.spacingY*g+this.template.commit.spacingY*h,m=(f||d)&&Math.abs(this.x-this.parentCommit.x)>Math.abs(this.template.commit.spacingX),n=this.y===this.parentCommit.y;p(this.parent)&&(m||n)&&(l=0),e=a(l,i),c=this.parentCommit.branch.color}var q=Math.PI/7,r=d?this.parentCommit.x:this.x,s=d?this.parentCommit.y:this.y,t=this.template.commit.dot.size+this.template.arrow.offset,u=t*Math.cos(e)+r,v=t*Math.sin(e)+s,w=(t+b)*Math.cos(e-q)+r,x=(t+b)*Math.sin(e-q)+s,y=(t+b/2)*Math.cos(e)+r,z=(t+b/2)*Math.sin(e)+s,A=(t+b)*Math.cos(e+q)+r,B=(t+b)*Math.sin(e+q)+s;this.context.beginPath(),this.context.fillStyle=c,this.context.moveTo(u,v),this.context.lineTo(w,x),this.context.quadraticCurveTo(y,z,A,B),this.context.lineTo(A,B),this.context.fill()},e.prototype.get=function(a){var b={};switch(a){case"blackarrow":b={branch:{color:"#000000",lineWidth:4,spacingX:50,mergeStyle:"straight",labelRotation:0},commit:{spacingY:-60,dot:{size:12,strokeColor:"#000000",strokeWidth:7},message:{color:"black"}},arrow:{size:16,offset:2.5}};break;case"metro":default:b={colors:["#979797","#008fb5","#f1c109"],branch:{lineWidth:10,spacingX:50,labelRotation:0},commit:{spacingY:-80,dot:{size:14},message:{font:"normal 14pt Arial"}}}}return new e(b)},Array.prototype.every||(Array.prototype.every=function(a,b){var c,d;if(null===this)throw new TypeError("this is null or not defined");var e=Object(this),f=e.length>>>0;if("function"!=typeof a)throw new TypeError;for(arguments.length>1&&(c=b),d=0;f>d;){var g;if(d in e){g=e[d];var h=a.call(c,g,d,e);if(!h)return!1}d++}return!0}),window.GitGraph=a,window.GitGraph.Branch=b,window.GitGraph.Commit=c,window.GitGraph.Template=e}(); \ No newline at end of file +!function(){"use strict";function a(a){switch(a=q(a)?a:{},this.elementId="string"==typeof a.elementId?a.elementId:"gitGraph",this.author="string"==typeof a.author?a.author:"Sergio Flores ",this.reverseArrow=k(a.reverseArrow,!1),this.template="string"==typeof a.template||q(a.template)?this.newTemplate(a.template):a.template instanceof e?a.template:this.newTemplate("metro"),this.mode=a.mode||null,"compact"===this.mode&&(this.template.commit.message.display=!1),a.orientation){case"vertical-reverse":this.template.commit.spacingY*=-1,this.orientation="vertical-reverse",this.template.branch.labelRotation=r(a,"template.branch.labelRotation")?0:a.template.branch.labelRotation,this.template.commit.tag.spacingY*=-1;break;case"horizontal":this.template.commit.message.display=!1,this.template.commit.spacingX=this.template.commit.spacingY,this.template.branch.spacingY=this.template.branch.spacingX,this.template.commit.spacingY=0,this.template.branch.spacingX=0,this.orientation="horizontal",this.template.branch.labelRotation=r(a,"template.branch.labelRotation")?-90:a.template.branch.labelRotation,this.template.commit.tag.spacingX=-this.template.commit.spacingX,this.template.commit.tag.spacingY=this.template.branch.spacingY;break;case"horizontal-reverse":this.template.commit.message.display=!1,this.template.commit.spacingX=-this.template.commit.spacingY,this.template.branch.spacingY=this.template.branch.spacingX,this.template.commit.spacingY=0,this.template.branch.spacingX=0,this.orientation="horizontal-reverse",this.template.branch.labelRotation=r(a,"template.branch.labelRotation")?90:a.template.branch.labelRotation,this.template.commit.tag.spacingX=-this.template.commit.spacingY,this.template.commit.tag.spacingY=this.template.branch.spacingY;break;default:this.orientation="vertical",this.template.branch.labelRotation=r(a,"template.branch.labelRotation")?0:a.template.branch.labelRotation}this.marginX=this.template.branch.spacingX+2*this.template.commit.dot.size,this.marginY=this.template.branch.spacingY+2*this.template.commit.dot.size,this.offsetX=0,this.offsetY=0,this.canvas=document.getElementById(this.elementId)||a.canvas,this.context=this.canvas.getContext("2d"),this.context.textBaseline="center",this.tooltip=document.createElement("div"),this.tooltip.className="gitgraph-tooltip",this.tooltip.style.position="fixed",this.tooltip.style.display="none",document.body.appendChild(this.tooltip),this.HEAD=null,this.branches=[],this.commits=[],this.columnMax=0,this.commitOffsetX=a.initCommitOffsetX||0,this.commitOffsetY=a.initCommitOffsetY||0,this.mouseMoveOptions={handleEvent:this.hover,gitgraph:this},this.canvas.addEventListener("mousemove",this.mouseMoveOptions,!1),this.mouseDownOptions={handleEvent:this.click,gitgraph:this},this.canvas.addEventListener("mousedown",this.mouseDownOptions,!1),window.onresize=this.render.bind(this)}function b(b){if(b.parent instanceof a!=!1){if(b=q(b)?b:{},this.parent=b.parent,b.parentCommit&&b.parentBranch){if(b.parentCommit.branch!==b.parentBranch)return;this.parentCommit=b.parentCommit,this.parentBranch=b.parentBranch}else b.parentCommit?(this.parentCommit=b.parentCommit,this.parentBranch=b.parentCommit.branch):b.parentBranch?(this.parentCommit=h(b.parentBranch),this.parentBranch=b.parentBranch):(this.parentCommit=null,this.parentBranch=null);this.name="string"==typeof b.name?b.name:"no-name",this.commitDefaultOptions=q(b.commitDefaultOptions)?b.commitDefaultOptions:{},this.context=this.parent.context,this.template=this.parent.template,this.lineWidth=b.lineWidth||this.template.branch.lineWidth,this.lineDash=b.lineDash||this.template.branch.lineDash,this.showLabel=k(b.showLabel,this.template.branch.showLabel),this.spacingX=this.template.branch.spacingX,this.spacingY=this.template.branch.spacingY,this.size=0,this.height=0,this.width=0,this.commits=[],this.path=[],"number"==typeof b.column?this.column=b.column:(this.column=0,this.calculColumn()),this.parent.columnMax=this.column>this.parent.columnMax?this.column:this.parent.columnMax,this.offsetX=this.column*this.spacingX,this.offsetY=this.column*this.spacingY,this.startPoint=this.parentBranch&&this.parentCommit?this.parentCommit===h(this.parentBranch)&&this.commits.length>0?{x:this.parentBranch.offsetX-this.parent.commitOffsetX+this.template.commit.spacingX,y:this.parentBranch.offsetY-this.parent.commitOffsetY+this.template.commit.spacingY,type:"start"}:{x:this.parentCommit.x,y:this.parentCommit.y,type:"start"}:null;var c=this.column%this.template.colors.length;this.color=b.color||this.template.branch.color||this.template.colors[c],this.checkout()}}function c(b){b.parent instanceof a!=!1&&(b=q(b)?b:{},this.parent=b.parent,this.template=this.parent.template,this.context=this.parent.context,this.branch=b.branch,this.author=b.author||this.parent.author,this.date=b.date||(new Date).toUTCString(),this.detail=b.detail||null,this.sha1=b.sha1||Math.random(100).toString(16).substring(3,10),this.message=b.message||"He doesn't like George Michael! Boooo!",this.arrowDisplay=b.arrowDisplay,this.messageDisplay=k(b.messageDisplay,this.template.commit.message.display),this.messageAuthorDisplay=k(b.messageAuthorDisplay,this.template.commit.message.displayAuthor),this.messageBranchDisplay=k(b.messageBranchDisplay,this.template.commit.message.displayBranch),this.messageHashDisplay=k(b.messageHashDisplay,this.template.commit.message.displayHash),this.messageColor=b.messageColor||b.color,this.messageFont=b.messageFont||this.template.commit.message.font,this.dotColor=b.dotColor||b.color,this.dotSize=b.dotSize||this.template.commit.dot.size,this.dotStrokeWidth=b.dotStrokeWidth||this.template.commit.dot.strokeWidth,this.dotStrokeColor=b.dotStrokeColor||this.template.commit.dot.strokeColor||b.color,this.type=b.type||null,this.tooltipDisplay=k(b.tooltipDisplay,!0),this.onClick=b.onClick||null,this.representedObject=b.representedObject||null,this.parentCommit=b.parentCommit,this.x=b.x,this.y=b.y,this.showLabel=b.showLabel,this.labelColor=b.labelColor||b.color,this.labelFont=b.labelFont||this.template.branch.labelFont,g(this,b),this.parent.commits.push(this))}function d(a,b){if(!q(a))throw new Error("You can't tag a commit that doesn't exist");b=q(b)?b:{},this.color=b.color||a.color,this.font=b.font||a.template.commit.tag.font;var c=a.context.font;a.context.font=this.font;var d=a.context.measureText(a.tag).width;this.width=Math.max(a.template.commit.tag.spacingX,d),a.parent.tagNum++;var e=0,f=0;return p(a.parent)?(e=a.x-a.dotSize/2,f=(a.parent.columnMax+1)*a.template.commit.tag.spacingY-a.template.commit.tag.spacingY/2+a.parent.tagNum%2*j(this.font)*1.5):(e=(a.parent.columnMax+1)*a.template.commit.tag.spacingX-a.template.commit.tag.spacingX/2+d/2,f=a.y-a.dotSize/2),l(a.context,e,f,a.tag,this.color,this.font,0,a.displayTagBox),a.context.font=c,this}function e(a){a=q(a)?a:{},a.branch=a.branch||{},a.arrow=a.arrow||{},a.commit=a.commit||{},a.commit.dot=a.commit.dot||{},a.commit.tag=a.commit.tag||{},a.commit.message=a.commit.message||{},this.colors=a.colors||["#6963FF","#47E8D4","#6BDB52","#E84BA5","#FFA657"],this.branch={},this.branch.color=a.branch.color||null,this.branch.lineWidth=a.branch.lineWidth||2,this.branch.lineDash=a.branch.lineDash||[],this.branch.showLabel=a.branch.showLabel||!1,this.branch.labelColor=a.branch.labelColor||null,this.branch.labelFont=a.branch.labelFont||"normal 8pt Calibri",this.branch.labelRotation=void 0!==a.branch.labelRotation?a.branch.labelRotation:null,this.branch.mergeStyle=a.branch.mergeStyle||"bezier",this.branch.spacingX="number"==typeof a.branch.spacingX?a.branch.spacingX:20,this.branch.spacingY=a.branch.spacingY||0,this.arrow={},this.arrow.size=a.arrow.size||null,this.arrow.color=a.arrow.color||null,this.arrow.active="number"==typeof this.arrow.size,this.arrow.offset=a.arrow.offset||2,this.commit={},this.commit.spacingX=a.commit.spacingX||0,this.commit.spacingY="number"==typeof a.commit.spacingY?a.commit.spacingY:25,this.commit.widthExtension="number"==typeof a.commit.widthExtension?a.commit.widthExtension:0,this.commit.tooltipHTMLFormatter=a.commit.tooltipHTMLFormatter||null,this.commit.shouldDisplayTooltipsInCompactMode=k(a.commit.shouldDisplayTooltipsInCompactMode,!0),this.commit.color=a.commit.color||null,this.commit.dot={},this.commit.dot.color=a.commit.dot.color||null,this.commit.dot.size=a.commit.dot.size||3,this.commit.dot.strokeWidth=a.commit.dot.strokeWidth||null,this.commit.dot.strokeColor=a.commit.dot.strokeColor||null,this.commit.tag={},this.commit.tag.color=a.commit.tag.color||this.commit.dot.color,this.commit.tag.font=a.commit.tag.font||a.commit.message.font||"normal 10pt Calibri",this.commit.tag.spacingX=this.branch.spacingX,this.commit.tag.spacingY=this.commit.spacingY,this.commit.message={},this.commit.message.display=k(a.commit.message.display,!0),this.commit.message.displayAuthor=k(a.commit.message.displayAuthor,!0),this.commit.message.displayBranch=k(a.commit.message.displayBranch,!0),this.commit.message.displayHash=k(a.commit.message.displayHash,!0),this.commit.message.color=a.commit.message.color||null,this.commit.message.font=a.commit.message.font||"normal 12pt Calibri"}function f(a){return a.slice(-1)[0]}function g(a,b){a.tag=b.tag||null,a.tagColor=b.tagColor||a.messageColor,a.tagFont=b.tagFont||a.template.commit.tag.font,a.displayTagBox=k(b.displayTagBox,!0)}function h(a){return f(a.commits)?f(a.commits):a.parentBranch?h(a.parentBranch):null}function i(a){return JSON.parse(JSON.stringify(a))}function j(a){var b=document.getElementsByTagName("body")[0],c=document.createElement("div"),d=document.createTextNode("Mg");c.appendChild(d),c.setAttribute("style","font: "+a+";"),b.appendChild(c);var e=c.offsetHeight;return b.removeChild(c),e}function k(a,b){return"boolean"==typeof a?a:b}function l(a,b,c,d,e,f,g,h){a.save(),a.translate(b,c),a.rotate(g*(Math.PI/180)),a.textAlign="center",a.font=f;var i=a.measureText(d).width,k=j(f);h?(a.beginPath(),a.rect(-(i/2)-4,-(k/2)+2,i+8,k+2),a.fillStyle=e,a.fill(),a.lineWidth=2,a.strokeStyle="black",a.stroke(),a.fillStyle="black"):a.fillStyle=e,a.fillText(d,0,k/2),a.restore()}function m(a,b,c){var d;document.createEvent?(d=document.createEvent("HTMLEvents"),d.initEvent(b,!0,!0)):(d=document.createEventObject(),d.eventType=b),d.eventName=b,d.data=c||{},document.createEvent?a.dispatchEvent(d):a.fireEvent("on"+d.eventType,d)}function n(a){var b,c;return c=1,window.devicePixelRatio&&(b=a.webkitBackingStorePixelRatio||a.mozBackingStorePixelRatio||a.msBackingStorePixelRatio||a.oBackingStorePixelRatio||a.backingStorePixelRatio||1,c*=window.devicePixelRatio/b),c}function o(a){return"vertical"===a.orientation||"vertical-reverse"===a.orientation}function p(a){return"horizontal"===a.orientation||"horizontal-reverse"===a.orientation}function q(a){return"object"==typeof a}function r(a,b){return!b.split(".").every(function(b){return"object"==typeof a&&null!==a&&b in a?(a=a[b],!0):!1})}a.prototype.dispose=function(){this.canvas.removeEventListener("mousemove",this.mouseMoveOptions,!1),this.canvas.removeEventListener("mousedown",this.mouseDownOptions,!1)},a.prototype.branch=function(a){if("string"==typeof a){var c=a;a={},a.name=c}a=q(a)?a:{},a.parent=this,a.parentBranch=a.parentBranch||this.HEAD;var d=new b(a);return this.branches.push(d),d},a.prototype.orphanBranch=function(a){if("string"==typeof a){var c=a;a={},a.name=c}a=q(a)?a:{},a.parent=this;var d=new b(a);return this.branches.push(d),d},a.prototype.commit=function(a){return this.HEAD.commit(a),this},a.prototype.tag=function(a){return this.HEAD.tag(a),this},a.prototype.newTemplate=function(a){return"string"==typeof a?(new e).get(a):new e(a)},a.prototype.render=function(){this.scalingFactor=n(this.context);var a={x:Math.abs((this.columnMax+1)*this.template.branch.spacingX)+Math.abs(this.commitOffsetX)+2*this.marginX,y:Math.abs((this.columnMax+1)*this.template.branch.spacingY)+Math.abs(this.commitOffsetY)+2*this.marginY};this.template.commit.message.display&&(a.x+=800),a.x+=this.template.commit.widthExtension,this.canvas.style.width=a.x+"px",this.canvas.style.height=a.y+"px",this.canvas.width=a.x*this.scalingFactor,this.canvas.height=a.y*this.scalingFactor,this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.context.translate(this.marginX,this.marginY),this.template.commit.spacingY>0&&(this.context.translate(0,this.canvas.height-2*this.marginY),this.offsetY=this.canvas.height-2*this.marginY),this.template.commit.spacingX>0&&(this.context.translate(this.canvas.width-2*this.marginX,0),this.offsetX=this.canvas.width-2*this.marginX),this.context.scale(this.scalingFactor,this.scalingFactor);for(var b,c=this.branches.length-1;b=this.branches[c];c--)b.render();this.tagNum=0;for(var d,e=0;d=this.commits[e];e++)d.render();m(this.canvas,"graph:render",{id:this.elementId})},a.prototype.applyCommits=function(a,b){function c(a){var b=document.getElementById(a),c=b.getBoundingClientRect();return{top:c.top+document.body.scrollTop,left:c.left+document.body.scrollLeft}}for(var d,e=a.offsetX||a.pageX-c(this.elementId).left,f=a.offsetY||a.pageY-c(this.elementId).top,g=0;d=this.commits[g];g++){var h=d.x+(this.offsetX+this.marginX)/this.scalingFactor-e,i=d.y+(this.offsetY+this.marginY)/this.scalingFactor-f,j=Math.sqrt(Math.pow(h,2)+Math.pow(i,2)),k=j0){this.pushPath({x:this.startPoint.x-this.parentBranch.offsetX+this.offsetX-this.template.commit.spacingX,y:this.startPoint.y-this.parentBranch.offsetY+this.offsetY-this.template.commit.spacingY,type:"join"});var r=i(this.startPoint);r.type="join",this.parentBranch.pushPath(r)}}else o&&(q.type="start");return this.pushPath(q),this.parent.commitOffsetX+=this.template.commit.spacingX*(a.showLabel?2:1),this.parent.commitOffsetY+=this.template.commit.spacingY*(a.showLabel?2:1),null!==p.detail&&(p.detail.style.display="block",this.parent.commitOffsetY-=p.detail.clientHeight-40),this.parent.render(),this},b.prototype.tag=function(a){"string"==typeof a&&(a={tag:a}),a=q(a)?a:{};var b=f(this.commits);return q(b)&&(g(b,a),this.parent.render()),this},b.prototype.checkout=function(){this.parent.HEAD=this},b.prototype.delete=function(){this.isDeleted=!0},b.prototype.merge=function(a,c){var d=a||this.parent.HEAD;if(d instanceof b==!1||d===this)return this;var e=this.commits[0];if(!e)return console.log(this.name+" is already up-to-date with "+d.name),this;var g="Merge branch `"+this.name+"` into `"+d.name+"`";if("object"!=typeof c){var j=c;c={},c.message="string"==typeof j?j:g}else c.message=c.message||g;c.type="mergeCommit",c.parentCommit=h(this);var k=e.parentCommit,l=h(d),m=k&&k.sha1===l.sha1;if(c.fastForward&&m){var n=p(this.parent);if(this.color=d.color,n){var o=d.path[1].y;this.path.forEach(function(a){a.y=o})}else{var q=d.path[1].x;this.path.forEach(function(a){a.x=q})}this.commits.forEach(function(a){n?a.y=k.y:a.x=k.x,a.labelColor=k.labelColor,a.messageColor=k.messageColor,a.dotColor=k.dotColor,a.dotStrokeColor=k.dotStrokeColor})}else{d.commit(c);var r=f(d.commits),s={x:this.offsetX+this.template.commit.spacingX*(r.showLabel?3:2)-this.parent.commitOffsetX,y:this.offsetY+this.template.commit.spacingY*(r.showLabel?3:2)-this.parent.commitOffsetY,type:"join"};this.pushPath(i(s));var t={x:r.x,y:r.y,type:"end"};this.pushPath(t),s.type="start",this.pushPath(s)}return this.parent.render(),this.parent.HEAD=d,this},b.prototype.calculColumn=function(){for(var a,b=[],c=0;a=this.parent.branches[c];c++)a.isDeleted||(a.column in b||(b[a.column]=0),b[a.column]++);for(this.column=0;this.column in b&&0!==b[this.column];this.column++);},b.prototype.pushPath=function(a){var b=f(this.path);b?b.x===a.x&&b.y===a.y?"start"!==b.type&&"end"===a.type?b.type="end":"join"===a.type||this.path.push(a):"join"===a.type?(a.x-b.x)*this.template.commit.spacingX<0?this.path.push(a):(a.y-b.y)*this.template.commit.spacingY<0&&this.path.push(a):this.path.push(a):this.path.push(a)},c.prototype.render=function(){var a=this.template.commit.tag.spacingX,b=(this.parent.columnMax+1)*this.template.branch.spacingX+a;if(this.showLabel)if(p(this.parent)&&this.template.branch.labelRotation%180===0){var e=this.y-this.dotSize-j(this.labelFont);l(this.context,this.x,e,this.branch.name,this.labelColor,this.labelFont,this.template.branch.labelRotation,!0)}else l(this.context,this.x+this.template.commit.spacingX,this.y+this.template.commit.spacingY,this.branch.name,this.labelColor,this.labelFont,this.template.branch.labelRotation,!0);if(this.context.beginPath(),this.context.arc(this.x,this.y,this.dotSize,0,2*Math.PI,!1),this.context.fillStyle=this.dotColor,this.context.strokeStyle=this.dotStrokeColor,this.context.lineWidth=this.dotStrokeWidth,"number"==typeof this.dotStrokeWidth&&this.context.stroke(),this.context.fill(),this.context.closePath(),this.arrowDisplay&&this.parentCommit instanceof c&&this.arrow(),null!==this.tag){var f=new d(this,{color:this.tagColor,font:this.tagFont});b+=f.width-a}if(null!==this.detail&&(this.detail.style.left=this.parent.canvas.offsetLeft+b+this.x+30+"px",this.detail.style.top=this.parent.canvas.offsetTop+this.y+40+"px",this.detail.width=30),this.messageDisplay){var g=this.message;this.messageHashDisplay&&(g=this.sha1+" "+g),this.messageAuthorDisplay&&(g+=this.author?" - "+this.author:""),this.messageBranchDisplay&&(g=(this.branch.name?"["+this.branch.name+"] ":"")+g),this.context.font=this.messageFont,this.context.fillStyle=this.messageColor,this.context.fillText(g,b,this.y+this.dotSize/2)}},c.prototype.arrow=function(){function a(a,b){var c=d?-1:1;return Math.atan2(c*a,c*b)}var b=this.template.arrow.size,c=this.template.arrow.color||this.branch.color,d=this.parent.reverseArrow,e=a(this.parentCommit.y-this.y,this.parentCommit.x-this.x),f=this===this.branch.commits[0];if("mergeCommit"===this.type||f){var g=this.parentCommit.branch.column-this.branch.column,h=this.showLabel?2:1,i=this.template.branch.spacingX*g+this.template.commit.spacingX*h,j=(f||d)&&Math.abs(this.y-this.parentCommit.y)>Math.abs(this.template.commit.spacingY),k=this.x===this.parentCommit.x;o(this.parent)&&(j||k)&&(i=0);var l=this.template.branch.spacingY*g+this.template.commit.spacingY*h,m=(f||d)&&Math.abs(this.x-this.parentCommit.x)>Math.abs(this.template.commit.spacingX),n=this.y===this.parentCommit.y;p(this.parent)&&(m||n)&&(l=0),e=a(l,i),c=this.parentCommit.branch.color}var q=Math.PI/7,r=d?this.parentCommit.x:this.x,s=d?this.parentCommit.y:this.y,t=this.template.commit.dot.size+this.template.arrow.offset,u=t*Math.cos(e)+r,v=t*Math.sin(e)+s,w=(t+b)*Math.cos(e-q)+r,x=(t+b)*Math.sin(e-q)+s,y=(t+b/2)*Math.cos(e)+r,z=(t+b/2)*Math.sin(e)+s,A=(t+b)*Math.cos(e+q)+r,B=(t+b)*Math.sin(e+q)+s;this.context.beginPath(),this.context.fillStyle=c,this.context.moveTo(u,v),this.context.lineTo(w,x),this.context.quadraticCurveTo(y,z,A,B),this.context.lineTo(A,B),this.context.fill()},e.prototype.get=function(a){var b={};switch(a){case"blackarrow":b={branch:{color:"#000000",lineWidth:4,spacingX:50,mergeStyle:"straight",labelRotation:0},commit:{spacingY:-60,dot:{size:12,strokeColor:"#000000",strokeWidth:7},message:{color:"black"}},arrow:{size:16,offset:2.5}};break;case"metro":default:b={colors:["#979797","#008fb5","#f1c109"],branch:{lineWidth:10,spacingX:50,labelRotation:0},commit:{spacingY:-80,dot:{size:14},message:{font:"normal 14pt Arial"}}}}return new e(b)},Array.prototype.every||(Array.prototype.every=function(a,b){var c,d;if(null===this)throw new TypeError("this is null or not defined");var e=Object(this),f=e.length>>>0;if("function"!=typeof a)throw new TypeError;for(arguments.length>1&&(c=b),d=0;f>d;){var g;if(d in e){g=e[d];var h=a.call(c,g,d,e);if(!h)return!1}d++}return!0}),window.GitGraph=a,window.GitGraph.Branch=b,window.GitGraph.Commit=c,window.GitGraph.Template=e}(); \ No newline at end of file diff --git a/docs/Branch.html b/docs/Branch.html index f090f0e8..28eb9a7c 100644 --- a/docs/Branch.html +++ b/docs/Branch.html @@ -593,7 +593,7 @@
This:
Source:
@@ -665,7 +665,7 @@
This:
Source:
@@ -939,7 +939,7 @@
This:
Source:
@@ -1187,7 +1187,7 @@
Properties
Source:
@@ -1282,7 +1282,7 @@
This:
Source:
@@ -1648,7 +1648,7 @@
Properties
Source:
@@ -1702,7 +1702,7 @@

Index

Classes

  • diff --git a/docs/Commit.html b/docs/Commit.html index 9225af56..dd61a889 100644 --- a/docs/Commit.html +++ b/docs/Commit.html @@ -1335,7 +1335,7 @@
    Properties
    Source:
    @@ -1425,7 +1425,7 @@
    This:
    Source:
    @@ -1497,7 +1497,7 @@
    This:
    Source:
    @@ -1544,7 +1544,7 @@

    Index

    Classes

    • diff --git a/docs/GitGraph.html b/docs/GitGraph.html index ad754c1e..9ee60703 100644 --- a/docs/GitGraph.html +++ b/docs/GitGraph.html @@ -1845,7 +1845,7 @@

      Index

      Classes

      • diff --git a/docs/Tag.html b/docs/Tag.html index 29ccfdd7..425e3cff 100644 --- a/docs/Tag.html +++ b/docs/Tag.html @@ -281,7 +281,7 @@
        Properties
        Source:
        @@ -360,7 +360,7 @@

        Index

        Classes

        • diff --git a/docs/Template.html b/docs/Template.html index 78d2661c..67221753 100644 --- a/docs/Template.html +++ b/docs/Template.html @@ -1093,7 +1093,7 @@
          Properties
          Source:
          @@ -1228,7 +1228,7 @@
          Parameters:
          Source:
          @@ -1297,7 +1297,7 @@

          Index

          Classes

          • diff --git a/docs/gitgraph.js.html b/docs/gitgraph.js.html index 46b252a7..e777f2ca 100644 --- a/docs/gitgraph.js.html +++ b/docs/gitgraph.js.html @@ -547,8 +547,8 @@

            Source: gitgraph.js

            this.offsetY = this.column * this.spacingY; // Add start point - if (this.parentBranch) { - if (this.parentCommit === _getParentCommitFromBranch(this.parentBranch)) { + if (this.parentBranch && this.parentCommit) { + if (this.parentCommit === _getParentCommitFromBranch(this.parentBranch) && this.commits.length > 0) { this.startPoint = { x: this.parentBranch.offsetX - this.parent.commitOffsetX + this.template.commit.spacingX, y: this.parentBranch.offsetY - this.parent.commitOffsetY + this.template.commit.spacingY, @@ -739,8 +739,7 @@

            Source: gitgraph.js

            var isFirstBranch = !(options.parentCommit instanceof Commit); var isPathBeginning = this.path.length === 0; - options.showLabel = (isPathBeginning && this.showLabel) ? true : false; - + options.showLabel = (isPathBeginning && this.showLabel); if (options.showLabel) { options.x -= this.template.commit.spacingX; options.y -= this.template.commit.spacingY; @@ -864,6 +863,12 @@

            Source: gitgraph.js

            return this; } + var firstBranchCommit = this.commits[0]; + if (!firstBranchCommit) { + console.log(this.name + " is already up-to-date with " + targetBranch.name); + return this; + } + // Merge commit var defaultMessage = "Merge branch `" + this.name + "` into `" + targetBranch.name + "`"; if (typeof commitOptions !== "object") { @@ -876,9 +881,9 @@

            Source: gitgraph.js

            commitOptions.type = "mergeCommit"; commitOptions.parentCommit = _getParentCommitFromBranch(this); - var branchParentCommit = this.commits[0].parentCommit; - var parentBranchLastCommit = _getLast(targetBranch.commits); - var isFastForwardPossible = (branchParentCommit.sha1 === parentBranchLastCommit.sha1); + var branchParentCommit = firstBranchCommit.parentCommit; + var targetBranchParentCommit = _getParentCommitFromBranch(targetBranch); + var isFastForwardPossible = (branchParentCommit && branchParentCommit.sha1 === targetBranchParentCommit.sha1); if (commitOptions.fastForward && isFastForwardPossible) { var isGraphHorizontal  = _isHorizontal(this.parent); this.color = targetBranch.color; @@ -1814,7 +1819,7 @@

            Index

            Classes