Skip to content

Commit

Permalink
improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
lowlighter committed Oct 6, 2022
1 parent ed62990 commit 66073f6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions source/plugins/languages/analyzer/analyzer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ export class Analyzer {
throw new TypeError(`"${repository}" pattern is not supported`)
const {login, name, ...groups} = repository.match(this.parser)?.groups ?? {}
repository = {owner:{login}, name}
branch = branch ?? groups.branch
ref = ref ?? groups.ref
if (groups.branch)
branch = groups.branch
if (groups.ref)
ref = groups.ref
}
const repo = `${repository.owner.login}/${repository.name}`
const path = paths.join(os.tmpdir(), `${this.uid}-${repo.replace(/[^\w]/g, "_")}`)
Expand Down
6 changes: 4 additions & 2 deletions source/plugins/languages/analyzer/indepth.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,18 @@ export class IndepthAnalyzer extends Analyzer {
const cache = {files:{}, languages:{}}
const result = {total:0, files:0, missed:{lines:0, bytes:0}, lines:{}, stats:{}, languages:{}}
const edited = new Set()
const seen = new Set()
for (const edition of commit.editions) {
edited.add(edition.path)

//Guess file language with linguist
if (!(edition.path in cache.files)) {
//Guess file language with linguist (only run it once per sha)
if ((!(edition.path in cache.files))&&(!seen.has(commit.sha))) {
this.debug(`language for file ${edition.path} is not in cache, running linguist at ${commit.sha}`)
await this.shell.run(`git checkout ${commit.sha}`, {cwd: path, env: {LANG: "en_GB"}}, {log: false, prefixed: false})
const {files: {results: files}, languages: {results: languages}} = await linguist(path)
Object.assign(cache.files, files)
Object.assign(cache.languages, languages)
seen.add(commit.sha)
}
if (!(edition.path in cache.files))
cache.files[edition.path] = "<unknown>"
Expand Down

0 comments on commit 66073f6

Please sign in to comment.