1 | |||
2 | 1 | var fs = require('fs'); |
|
3 | 1 | var glob = require('glob'); |
|
4 | 1 | var globAll = require('glob-all'); |
|
5 | 1 | var path = require('path'); |
|
6 | 1 | var extend = require('util')._extend; |
|
7 | 1 | var format = require('string-template'); |
|
8 | 1 | var frontMatter = require('front-matter'); |
|
9 | 1 | var yaml = require('js-yaml'); |
|
10 | |||
11 | 1 | var git = require('../util/git'); |
|
12 | |||
13 | 1 | module.exports = function(value, config, cb, pl) { |
|
14 | 2 | var data = getGitInfo (value, config, pl); |
|
15 | //config.$PL.debug('gitinfo:', data); |
||
16 | 2 | cb(null, processTree(data, config)); |
|
17 | } |
||
18 | |||
19 | 1 | module.exports.config = { |
|
20 | verbose: false |
||
21 | } |
||
22 | |||
23 | 1 | module.exports.search = function(items, link) { |
|
0 ignored issues
–
show
|
|||
24 | 1 | var results = []; |
|
25 | // this => collider |
||
26 | /* results.push({ |
||
27 | name: name, |
||
28 | type: 'sass ' + type, |
||
29 | description: description, |
||
30 | link: link + hash |
||
31 | }); */ |
||
32 | |||
33 | 1 | return results; |
|
34 | } |
||
35 | |||
36 | |||
37 | function getGitInfo(value, config, pl) { |
||
38 | 2 | if (!fs.existsSync(value)) return false; |
|
39 | var logFormatYaml = |
||
40 | 1 | '- date: \'%cd\''+'%n'+ |
|
41 | ' timestamp: %ct'+'%n'+ |
||
42 | ' author: %an'+'%n'+ |
||
43 | ' email: %ae'+'%n'+ |
||
44 | ' message: \'\"%s\"\''+'%n'+ |
||
45 | ' commit: %h'+'%n'+ |
||
46 | ' hash: %H'+'%n'+ |
||
47 | ' body: \'\"%b\"\''+'%n'+ |
||
48 | '%n'; |
||
49 | |||
50 | var logFormatCompact = |
||
51 | 1 | '### %cd'+'%n'+ |
|
52 | '%n'+ |
||
53 | '- %s (%h, by [%an](mailto:%ae), <%ae>)'+'%n'+ |
||
54 | '%n'+ |
||
55 | '%n'; |
||
56 | |||
57 | var logFormatFull = |
||
58 | 1 | '### %cD'+'%n'+ |
|
59 | '%n'+ |
||
60 | '- Author: [%an](mailto:%ae) (<%ae>)'+'%n'+ |
||
61 | '%n'+ |
||
62 | ' Commit: %H'+'%n'+ |
||
63 | '%n'+ |
||
64 | ' Message: %s'+'%n'+ |
||
65 | '%n'+ |
||
66 | //' Body: \'%b\''+'%n'+ |
||
67 | //'%n'+ |
||
68 | //' \\`\\`\\`diff'+'%n'+ |
||
69 | //' \`git diff %H '+value+'\`'+'%n'+ |
||
70 | //' \\`\\`\\`'+'%n'+ |
||
71 | '%n'; |
||
72 | |||
73 | |||
74 | 1 | var logData = yaml.load( getGitLog(value, logFormatYaml, config) ); |
|
75 | 1 | var logCompact = getGitLog(value, logFormatCompact, config); |
|
76 | 1 | var logFull = getGitLog(value, logFormatFull, config); |
|
77 | |||
78 | 1 | return { |
|
79 | log: { |
||
80 | data: logData, |
||
81 | list: pl.markdown.render(String(logCompact)), |
||
82 | full: pl.markdown.render(String(logFull)) |
||
83 | } |
||
84 | }; |
||
85 | } |
||
86 | |||
87 | |||
88 | function processTree(tree, config) { |
||
0 ignored issues
–
show
|
|||
89 | |||
90 | 2 | var logs = {}; |
|
91 | 4 | if (tree && tree.log) { |
|
92 | 1 | for (var i in tree.log.data) { |
|
93 | 1 | var obj = tree.log.data[i]; |
|
94 | 1 | var logdate = obj.date; |
|
95 | |||
96 | 2 | if (!logs[logdate]) { logs[logdate] = []; } |
|
97 | 1 | logs[logdate].push(obj); |
|
98 | } |
||
99 | 1 | tree.log.data = logs; |
|
100 | } |
||
101 | |||
102 | 2 | return tree; |
|
103 | } |
||
104 | |||
105 | function getGitLog ( filepath, logFormat, config ) { |
||
0 ignored issues
–
show
|
|||
106 | 3 | var gitLog = git.log( filepath, 'format:"'+logFormat+'"' ); |
|
107 | 3 | return gitLog; |
|
108 | } |
||
109 | |||
110 | |||
111 |
This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.