@dotinc/ogre-react 0.3.0 → 0.3.1-canary.145.7942729114.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/OgreGraph.tsx +18 -20
- package/index.tsx +2 -2
- package/package.json +5 -5
- package/git2json.tsx +0 -53
package/OgreGraph.tsx
CHANGED
|
@@ -1,29 +1,27 @@
|
|
|
1
|
-
import React, {useEffect, useState} from
|
|
2
|
-
|
|
3
|
-
import {RepositoryObject} from
|
|
4
|
-
import {
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
|
+
|
|
3
|
+
import { formatGit2Json, RepositoryObject } from "@dotinc/ogre";
|
|
4
|
+
import { Gitgraph } from "@gitgraph/react";
|
|
5
5
|
|
|
6
6
|
export interface OgreGraphProps {
|
|
7
|
-
repository: RepositoryObject<any
|
|
7
|
+
repository: RepositoryObject<any>;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export const OgreGraph: React.FC<OgreGraphProps> = ({repository}) => {
|
|
11
|
-
const [graphData, setGraphData] = useState<any[] | undefined>(undefined)
|
|
10
|
+
export const OgreGraph: React.FC<OgreGraphProps> = ({ repository }) => {
|
|
11
|
+
const [graphData, setGraphData] = useState<any[] | undefined>(undefined);
|
|
12
12
|
|
|
13
13
|
useEffect(() => {
|
|
14
14
|
if (!graphData) {
|
|
15
|
-
const history = repository.getHistory()
|
|
16
|
-
setGraphData(formatGit2Json(history))
|
|
15
|
+
const history = repository.getHistory();
|
|
16
|
+
setGraphData(formatGit2Json(history));
|
|
17
17
|
}
|
|
18
|
-
}, [repository])
|
|
18
|
+
}, [repository]);
|
|
19
19
|
|
|
20
|
-
return !graphData
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
)
|
|
29
|
-
}
|
|
20
|
+
return !graphData ? null : (
|
|
21
|
+
<Gitgraph>
|
|
22
|
+
{(gitgraph) => {
|
|
23
|
+
gitgraph.import(graphData);
|
|
24
|
+
}}
|
|
25
|
+
</Gitgraph>
|
|
26
|
+
);
|
|
27
|
+
};
|
package/index.tsx
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export {formatGit2Json} from
|
|
1
|
+
export * from "./OgreGraph";
|
|
2
|
+
export { formatGit2Json } from "@dotinc/ogre";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotinc/ogre-react",
|
|
3
|
-
"version": "0.3.0",
|
|
3
|
+
"version": "0.3.1-canary.145.7942729114.0",
|
|
4
4
|
"main": "./index.tsx",
|
|
5
5
|
"types": "./index.tsx",
|
|
6
6
|
"license": "MIT",
|
|
@@ -9,19 +9,19 @@
|
|
|
9
9
|
"url": "https://github.com/dotindustries/ogre.git"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@dotinc/ogre": "
|
|
12
|
+
"@dotinc/ogre": "0.3.1-canary.145.7942729114.0",
|
|
13
13
|
"@gitgraph/react": "^1.6.0"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@types/react": "^17.0.39",
|
|
17
17
|
"@types/react-dom": "^17.0.13",
|
|
18
|
-
"config": "
|
|
18
|
+
"config": "0.1.2-canary.145.7942729114.0",
|
|
19
19
|
"tsconfig": "^0.1.1",
|
|
20
|
-
"typescript": "^4.
|
|
20
|
+
"typescript": "^4.7.4"
|
|
21
21
|
},
|
|
22
22
|
"publishConfig": {
|
|
23
23
|
"registry": "https://registry.npmjs.org/",
|
|
24
24
|
"access": "public"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "0be07a773b75d40f9bca1153a9f4af957237ae2b"
|
|
27
27
|
}
|
package/git2json.tsx
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import {cleanAuthor, Commit, createHeadRefValue, History, isTagRef, Reference, REFS_HEAD_KEY} from '@dotinc/ogre'
|
|
2
|
-
|
|
3
|
-
const findRefs = (commit: Commit, refs: Map<string, Reference>) => {
|
|
4
|
-
const list = []
|
|
5
|
-
const headRef = refs.get(REFS_HEAD_KEY)
|
|
6
|
-
for (const [key, ref] of refs.entries()) {
|
|
7
|
-
if (ref.value === commit.hash) {
|
|
8
|
-
if (isTagRef(key)) {
|
|
9
|
-
list.push(`tag: ${ref.name}`)
|
|
10
|
-
} else {
|
|
11
|
-
list.push(ref.name)
|
|
12
|
-
}
|
|
13
|
-
// also check if HEAD is pointing to this ref
|
|
14
|
-
if (headRef && headRef.value === createHeadRefValue(key)) {
|
|
15
|
-
list.push(headRef.name)
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return list
|
|
20
|
-
}
|
|
21
|
-
// format
|
|
22
|
-
export const formatGit2Json = (history: History) => {
|
|
23
|
-
const {commits, refs} = history
|
|
24
|
-
return commits.reverse().map(c => {
|
|
25
|
-
const [name, email] = cleanAuthor(c.author)
|
|
26
|
-
|
|
27
|
-
return {
|
|
28
|
-
'refs': findRefs(c, refs),
|
|
29
|
-
'hash': c.hash,
|
|
30
|
-
'hashAbbrev': c.hash.substring(0, 8),
|
|
31
|
-
'tree': c.tree,
|
|
32
|
-
'treeAbbrev': c.tree.substring(0, 8),
|
|
33
|
-
// FIXME there is only one parent at the moment on ogre
|
|
34
|
-
'parents': c.parent ? [c.parent] : [],
|
|
35
|
-
'parentsAbbrev': c.parent ? [c.parent.substring(0, 8)] : [],
|
|
36
|
-
committer: {
|
|
37
|
-
name,
|
|
38
|
-
email,
|
|
39
|
-
date: c.timestamp.getMilliseconds()
|
|
40
|
-
},
|
|
41
|
-
author: {
|
|
42
|
-
name,
|
|
43
|
-
email,
|
|
44
|
-
timestamp: c.timestamp.getMilliseconds()
|
|
45
|
-
},
|
|
46
|
-
'subject': c.message,
|
|
47
|
-
'body': '',
|
|
48
|
-
'notes': '',
|
|
49
|
-
// MAYBE? map changes to {additions: number, deletions: number, file: string}
|
|
50
|
-
'stats': []
|
|
51
|
-
}
|
|
52
|
-
})
|
|
53
|
-
}
|