Skip to content

Commit b38aca3

Browse files
committed
update README
Signed-off-by: Terrence Lee <[email protected]>
1 parent 6b5a695 commit b38aca3

File tree

5 files changed

+62
-16
lines changed

5 files changed

+62
-16
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ modification, are permitted provided that the following conditions are met:
88
* Redistributions in binary form must reproduce the above copyright
99
notice, this list of conditions and the following disclaimer in the
1010
documentation and/or other materials provided with the distribution.
11-
* Neither the name of the <organization> nor the
11+
* Neither the name of the fgdev nor the
1212
names of its contributors may be used to endorse or promote products
1313
derived from this software without specific prior written permission.
1414

README

Lines changed: 0 additions & 5 deletions
This file was deleted.

README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
gitgraph.js
2+
=======
3+
gitgraph.js a tool for converting "git log --graph" from pure ascii characters graph to a canvas image.
4+
5+
Quick Start (with PHP demo)
6+
-----
7+
1. Get a copy of this repo (clone or [download tarball](http://github.com/bluef/gitgraph.js/tarball/master))
8+
2. Put everything in the directory where PHP file can be excuted
9+
3. Edit example.php, change the value of GIT_REPO_PATH on line 2 to the path of your repo
10+
11+
define("GIT_REPO_PATH", "/path/to/your/repo");
12+
13+
4. Go visit example.php in your browser
14+
15+
Miscellaneous
16+
------------
17+
jQuery is only for parsing DOM
18+
19+
License
20+
-------
21+
Copyright (c) 2011, Terrence Lee <[email protected]>
22+
All rights reserved.
23+
24+
Redistribution and use in source and binary forms, with or without
25+
modification, are permitted provided that the following conditions are met:
26+
* Redistributions of source code must retain the above copyright
27+
notice, this list of conditions and the following disclaimer.
28+
* Redistributions in binary form must reproduce the above copyright
29+
notice, this list of conditions and the following disclaimer in the
30+
documentation and/or other materials provided with the distribution.
31+
* Neither the name of the fgdev nor the
32+
names of its contributors may be used to endorse or promote products
33+
derived from this software without specific prior written permission.
34+
35+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
36+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
37+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38+
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
39+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
40+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
41+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
42+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
43+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
44+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

example.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
chdir(GIT_REPO_PATH);
55

6-
$cmd = 'git log --graph --date-order -C -M --all --date=iso --pretty=format:"B[%d] C[%H] D[%ad] A[%an] E[%ae] S[%s]"';
6+
$cmd = 'git log --graph --date-order -C -M -n 100 --date=iso --pretty=format:"B[%d] C[%H] D[%ad] A[%an] E[%ae] S[%s]"';
77

88
ob_clean();
99
ob_start();
@@ -27,12 +27,14 @@
2727
"subject"=>$output[9]
2828
);
2929
}
30+
31+
$title = "Git Graph of " . substr(GIT_REPO_PATH, strrpos(GIT_REPO_PATH, "/") + 1);
3032
?>
3133

3234
<!DOCTYPE html>
3335
<html>
3436
<head>
35-
<title>Git Graph</title>
37+
<title><?php echo $title; ?></title>
3638
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
3739
<script type="text/javascript" src="jquery.js"></script>
3840
<script type="text/javascript" src="gitgraph.js"></script>
@@ -43,7 +45,7 @@
4345
<body>
4446
<div id="header">
4547
<h2>
46-
Git Graph of <?php echo substr(GIT_REPO_PATH, strrpos(GIT_REPO_PATH, "/") + 1); ?>
48+
<?php echo $title; ?>
4749
</h2>
4850
</div>
4951
<div id="git-graph-container">

gitgraph.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,19 +171,24 @@ var gitGraph = function (canvas, rawGraphList, config) {
171171
var nodePos, outPos;
172172
var tempFlow;
173173
var prevRowLength = 0;
174-
var l = graphList.length;
175174
var flowSwapPos = -1;
176175
var lastLinePos;
177-
var i, k;
176+
var i, k, l;
178177
var condenseCurrentLength, condensePrevLength = 0, condenseNextLength = 0;
179178

180179
var inlineIntersect = false;
181180

182-
flows.push(genNewFlow()); //first flow
181+
//initiate for first row
182+
for (i = 0, l = graphList[0].length; i < l; i++) {
183+
if (graphList[0][i] !== "_" && graphList[0][i] !== " ") {
184+
flows.push(genNewFlow());
185+
}
186+
}
183187

184-
y = canvas.height - 0.5 * config.unitSize;
188+
y = canvas.height - config.unitSize * 0.5;
185189

186-
for (i = 0; i < l; i++) {
190+
//iterate
191+
for (i = 0, l = graphList.length; i < l; i++) {
187192
x = config.unitSize * 0.5;
188193

189194
currentRow = graphList[i];
@@ -281,7 +286,6 @@ var gitGraph = function (canvas, rawGraphList, config) {
281286
}
282287

283288
//change \ and / to | when it's in the last position of the whole row
284-
285289
if (colomn === "/" || colomn === "\\") {
286290
if (!(colomn === "/" && findBranchOut(nextRow) === -1)) {
287291
if ((lastLinePos = Math.max(findColomn("|", currentRow),
@@ -314,13 +318,14 @@ var gitGraph = function (canvas, rawGraphList, config) {
314318
return (val !== " " && val !== "_")
315319
}).length;
316320

321+
//do some clean up
317322
if (flows.length > condenseCurrentLength) {
318323
flows.splice(condenseCurrentLength, flows.length - condenseCurrentLength);
319324
}
320325

321326
colomnIndex = 0;
322327

323-
//draw
328+
//a little inline analysis and draw process
324329
while (colomnIndex < currentRow.length) {
325330
colomn = currentRow[colomnIndex];
326331
prevColomn = currentRow[colomnIndex - 1];

0 commit comments

Comments
 (0)