codekingpro/portable-devtools
115k
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 