Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
revs.js23 linesDownload Raw Back to lib
1const spawn = require('./spawn.js')
2const { LRUCache } = require('lru-cache')
3const linesToRevs = require('./lines-to-revs.js')
4
5const revsCache = new LRUCache({
6  max: 100,
7  ttl: 5 * 60 * 1000,
8})
9
10module.exports = async (repo, opts = {}) => {
11  if (!opts.noGitRevCache) {
12    const cached = revsCache.get(repo)
13    if (cached) {
14      return cached
15    }
16  }
17
18  const { stdout } = await spawn(['ls-remote', repo], opts)
19  const revs = linesToRevs(stdout.trim().split('\n'))
20  revsCache.set(repo, revs)
21  return revs
22}
23 
codekingpro/portable-devtools · Team Ai