MCPcopy
hub / github.com/lowlighter/metrics / filter

Method filter

source/plugins/languages/analyzer/indepth.mjs:92–125  ·  view source on GitHub ↗

Filter related commits in repository

(path, {ref})

Source from the content-addressed store, hash-verified

90
91 /**Filter related commits in repository */
92 async filter(path, {ref}) {
93 const commits = new Set()
94 try {
95 this.debug(`filtering commits authored by ${this.login} in ${path}`)
96 for (const author of this.authoring) {
97 //Search by --author
98 {
99 const output = await this.shell.run(`git log --author='${author}' --pretty=format:"%H" --regexp-ignore-case --no-merges`, {cwd: path, env: {LANG: "en_GB"}}, {log: false, debug: false, prefixed: false})
100 const hashes = output.split("\n").map(line => line.trim()).filter(line => this.markers.hash.test(line))
101 hashes.forEach(hash => commits.add(hash))
102 this.debug(`found ${hashes.length} for ${author} (using --author)`)
103 }
104 //Search by --grep
105 {
106 const output = await this.shell.run(`git log --grep='${author}' --pretty=format:"%H" --regexp-ignore-case --no-merges`, {cwd: path, env: {LANG: "en_GB"}}, {log: false, debug: false, prefixed: false})
107 const hashes = output.split("\n").map(line => line.trim()).filter(line => this.markers.hash.test(line))
108 hashes.forEach(hash => commits.add(hash))
109 this.debug(`found ${hashes.length} for ${author} (using --grep)`)
110 }
111 }
112 //Apply ref range if specified
113 if (ref) {
114 this.debug(`filtering commits referenced by ${ref} in ${path}`)
115 const output = await this.shell.run(`git rev-list --boundary ${ref}`, {cwd: path, env: {LANG: "en_GB"}}, {log: false, debug: false, prefixed: false})
116 const hashes = output.split("\n").map(line => line.trim()).filter(line => this.markers.hash.test(line))
117 commits.forEach(commit => !hashes.includes(commit) ? commits.delete(commit) : null)
118 }
119 this.debug(`found ${commits.size} unique commits authored by ${this.login} in ${path}`)
120 }
121 catch (error) {
122 this.debug(`an error occurred during filtering of commits authored by ${this.login} in ${path} (${error})`)
123 }
124 return [...commits]
125 }
126
127 /**Filter commits in repository */
128 async commits(path, {ref}) {

Callers 15

commitsMethod · 0.95
metricsFunction · 0.80
embedFunction · 0.80
setup.mjsFile · 0.80
metadata.mjsFile · 0.80
demosFunction · 0.80
presetsFunction · 0.80
githubFunction · 0.80
pieFunction · 0.80
index.mjsFile · 0.80
instance.mjsFile · 0.80
warningsFunction · 0.80

Calls 3

debugMethod · 0.80
addMethod · 0.80
runMethod · 0.45

Tested by 1

diffFunction · 0.64