Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite GitGraph.js #12137

Merged
merged 2 commits into from
Jul 5, 2020
Merged

Rewrite GitGraph.js #12137

merged 2 commits into from
Jul 5, 2020

Conversation

zeripath
Copy link
Contributor

@zeripath zeripath commented Jul 4, 2020

The current vendored gitgraph.js is no longer maintained and is
difficult to understand, fix and maintain.

This PR completely rewrites its logic - hopefully in a clearer fashion
and easier to maintain.

It also includes @silverwind's improvements of coloring the commit dots
and preventing the flash of incorrect content.

Further changes to contemplate in future will be abstracting out of the
flows to an object, storing the involved commit references on the flows
etc. However, this is probably a required step for this.

Replaces #12131
Fixes #11981 (part 3)

Signed-off-by: Andrew Thornton art27@cantab.net

@zeripath zeripath added this to the 1.13.0 milestone Jul 4, 2020
@zeripath
Copy link
Contributor Author

zeripath commented Jul 4, 2020

Although this is a rewrite it may be appropriate to backport to 1.12 as the gitgraph is broken there. Otherwise we could backport a simple hacky fix that will prevent the graph from disappearing by just assigning a '#000' flow whenever a flow is missing e.g. for 1.12 apply the below patch:

diff --git a/web_src/js/vendor/gitgraph.js b/web_src/js/vendor/gitgraph.js
index 0cf5d0f75..7a5777598 100644
--- a/web_src/js/vendor/gitgraph.js
+++ b/web_src/js/vendor/gitgraph.js
@@ -376,7 +376,18 @@ export default function gitGraph(canvas, rawGraphList, config) {
           flows.splice(colomnIndex, 0, genNewFlow());
         }
 
-        color = flows[colomnIndex].color;
+        if (colomnIndex < flows.length) {
+          color = flows[colomnIndex].color;
+        } else {
+          console.error({
+            message: "Missing flow!",
+            colomnIndex,
+            colomn,
+            prevColomn,
+            flowSwapPos,
+          });
+          color = "#000";
+        }
 
         switch (colomn) {
           case '-':

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jul 4, 2020
@zeripath
Copy link
Contributor Author

zeripath commented Jul 4, 2020

go.mod Outdated Show resolved Hide resolved
The current vendored gitgraph.js is no longer maintained and is
difficult to understand, fix and maintain.

This PR completely rewrites its logic - hopefully in a clearer fashion
and easier to maintain.

It also includes @silverwind's improvements of coloring the commit dots
and preventing the flash of incorrect content.

Further changes to contemplate in future will be abstracting out of the
flows to an object, storing the involved commit references on the flows
etc. However, this is probably a required step for this.

Replaces go-gitea#12131
Fixes go-gitea#11981 (part 3)

Signed-off-by: Andrew Thornton <art27@cantab.net>
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Jul 4, 2020
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Jul 5, 2020
@lafriks
Copy link
Member

lafriks commented Jul 5, 2020

🚀

@zeripath zeripath merged commit 2ab185d into go-gitea:master Jul 5, 2020
@zeripath zeripath deleted the fix-11981-part-3 branch July 5, 2020 01:05
ydelafollye pushed a commit to ydelafollye/gitea that referenced this pull request Jul 31, 2020
The current vendored gitgraph.js is no longer maintained and is
difficult to understand, fix and maintain.

This PR completely rewrites its logic - hopefully in a clearer fashion
and easier to maintain.

It also includes @silverwind's improvements of coloring the commit dots
and preventing the flash of incorrect content.

Further changes to contemplate in future will be abstracting out of the
flows to an object, storing the involved commit references on the flows
etc. However, this is probably a required step for this.

Replaces go-gitea#12131
Fixes go-gitea#11981 (part 3)

Signed-off-by: Andrew Thornton <art27@cantab.net>
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Damaged graph
4 participants