Merge branch 'no-bloat'

This commit is contained in:
Knut Sveidqvist 2019-06-09 07:00:29 -07:00
commit df7dc21893
6 changed files with 37 additions and 24 deletions

View File

@ -46,8 +46,8 @@
"dagre-layout": "^0.8.8",
"graphlibrary": "^2.2.0",
"he": "^1.2.0",
"lodash": "^4.17.11",
"moment": "^2.23.0",
"lodash": "^4.17.5",
"moment-mini": "^2.22.1",
"scope-css": "^1.2.1"
},
"devDependencies": {
@ -70,6 +70,7 @@
"jest-image-snapshot": "^2.8.2",
"jest-puppeteer": "^4.2.0",
"jison": "^0.4.18",
"moment": "^2.23.0",
"node-sass": "^4.11.0",
"puppeteer": "^1.17.0",
"sass-loader": "^7.1.0",
@ -81,8 +82,7 @@
"yarn-upgrade-all": "^0.5.0"
},
"files": [
"dist",
"src"
"dist"
],
"yarn-upgrade-all": {
"ignore": [

View File

@ -1,4 +1,4 @@
import moment from 'moment'
import moment from 'moment-mini'
import { logger } from '../../logger'
let dateFormat = ''

View File

@ -155,9 +155,9 @@ function prettyPrintCommitHistory (commitArr) {
}
})
const label = [line, commit.id, commit.seq]
_.each(branches, function (value, key) {
if (value === commit.id) label.push(key)
})
for (let branch in branches) {
if (branches[branch] === commit.id) label.push(branch)
}
logger.debug(label.join(' '))
if (Array.isArray(commit.parent)) {
const newCommit = commits[commit.parent[0]]
@ -188,9 +188,10 @@ export const clear = function () {
}
export const getBranchesAsObjArray = function () {
const branchArr = _.map(branches, function (value, key) {
return { 'name': key, 'commit': commits[value] }
})
const branchArr = []
for (let branch in branches) {
branchArr.push({ name: branch, commit: commits[branches[branch]] })
}
return branchArr
}

View File

@ -1,5 +1,5 @@
import _ from 'lodash'
import * as d3 from 'd3'
import _ from 'lodash'
import db from './gitGraphAst'
import gitGraphParser from './parser/gitGraph'
@ -160,7 +160,7 @@ function cloneNode (svg, selector) {
function renderCommitHistory (svg, commitid, branches, direction) {
let commit
const numCommits = Object.keys(allCommitsDict).length
if (_.isString(commitid)) {
if (typeof commitid === 'string') {
do {
commit = allCommitsDict[commitid]
logger.debug('in renderCommitHistory', commit.id, commit.seq)
@ -189,7 +189,13 @@ function renderCommitHistory (svg, commitid, branches, direction) {
.attr('stroke', config.nodeStrokeColor)
.attr('stroke-width', config.nodeStrokeWidth)
const branch = _.find(branches, ['commit', commit])
let branch
for (let branchName in branches) {
if (branches[branchName].commit === commit) {
branch = branches[branchName]
break
}
}
if (branch) {
logger.debug('found branch ', branch.name)
svg.select('#node-' + commit.id + ' p')
@ -211,7 +217,7 @@ function renderCommitHistory (svg, commitid, branches, direction) {
} while (commitid && allCommitsDict[commitid])
}
if (_.isArray(commitid)) {
if (Array.isArray(commitid)) {
logger.debug('found merge commmit', commitid)
renderCommitHistory(svg, commitid[0], branches, direction)
branchNum++
@ -223,11 +229,11 @@ function renderCommitHistory (svg, commitid, branches, direction) {
function renderLines (svg, commit, direction, branchColor) {
branchColor = branchColor || 0
while (commit.seq > 0 && !commit.lineDrawn) {
if (_.isString(commit.parent)) {
if (typeof commit.parent === 'string') {
svgDrawLineForCommits(svg, commit.id, commit.parent, direction, branchColor)
commit.lineDrawn = true
commit = allCommitsDict[commit.parent]
} else if (_.isArray(commit.parent)) {
} else if (Array.isArray(commit.parent)) {
svgDrawLineForCommits(svg, commit.id, commit.parent[0], direction, branchColor)
svgDrawLineForCommits(svg, commit.id, commit.parent[1], direction, branchColor + 1)
renderLines(svg, allCommitsDict[commit.parent[1]], direction, branchColor + 1)
@ -246,7 +252,7 @@ export const draw = function (txt, id, ver) {
// Parse the graph definition
parser.parse(txt + '\n')
config = _.extend(config, apiConfig, db.getOptions())
config = _.assign(config, apiConfig, db.getOptions())
logger.debug('effective options', config)
const direction = db.getDirection()
allCommitsDict = db.getCommits()
@ -259,11 +265,12 @@ export const draw = function (txt, id, ver) {
const svg = d3.select(`[id="${id}"]`)
svgCreateDefs(svg)
branchNum = 1
_.each(branches, function (v) {
for (let branch in branches) {
const v = branches[branch]
renderCommitHistory(svg, v.commit.id, branches, direction)
renderLines(svg, v.commit, direction)
branchNum++
})
}
svg.attr('height', function () {
if (direction === 'BT') return Object.keys(allCommitsDict).length * config.nodeSpacing
return (branches.length + 1) * config.branchOffset

View File

@ -1,4 +1,4 @@
import moment from 'moment'
import moment from 'moment-mini'
export const LEVELS = {
debug: 1,

View File

@ -6407,10 +6407,15 @@ mkdirp@0.5.1, mkdirp@0.5.x, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdi
dependencies:
minimist "0.0.8"
moment-mini@^2.22.1:
version "2.22.1"
resolved "https://registry.yarnpkg.com/moment-mini/-/moment-mini-2.22.1.tgz#bc32d73e43a4505070be6b53494b17623183420d"
integrity sha512-OUCkHOz7ehtNMYuZjNciXUfwTuz8vmF1MTbAy59ebf+ZBYZO5/tZKuChVWCX+uDo+4idJBpGltNfV8st+HwsGw==
moment@^2.23.0:
version "2.23.0"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.23.0.tgz#759ea491ac97d54bac5ad776996e2a58cc1bc225"
integrity sha512-3IE39bHVqFbWWaPOMHZF98Q9c3LDKGTmypMiTM2QygGXXElkFWIH7GxfmlwmY2vwa+wmNsoYZmG2iusf1ZjJoA==
version "2.24.0"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.24.0.tgz#0d055d53f5052aa653c9f6eb68bb5d12bf5c2b5b"
integrity sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==
move-concurrently@^1.0.1:
version "1.0.1"