Last change
on this file since b738035 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
640 bytes
|
Line | |
---|
1 | const pinflight = require('promise-inflight')
|
---|
2 | const spawn = require('./spawn.js')
|
---|
3 | const LRU = require('lru-cache')
|
---|
4 |
|
---|
5 | const revsCache = new LRU({
|
---|
6 | max: 100,
|
---|
7 | maxAge: 5 * 60 * 1000
|
---|
8 | })
|
---|
9 |
|
---|
10 | const linesToRevs = require('./lines-to-revs.js')
|
---|
11 |
|
---|
12 | module.exports = async (repo, opts = {}) => {
|
---|
13 | if (!opts.noGitRevCache) {
|
---|
14 | const cached = revsCache.get(repo)
|
---|
15 | if (cached) {
|
---|
16 | return cached
|
---|
17 | }
|
---|
18 | }
|
---|
19 |
|
---|
20 | return pinflight(`ls-remote:${repo}`, () =>
|
---|
21 | spawn(['ls-remote', repo], opts)
|
---|
22 | .then(({ stdout }) => linesToRevs(stdout.trim().split('\n')))
|
---|
23 | .then(revs => {
|
---|
24 | revsCache.set(repo, revs)
|
---|
25 | return revs
|
---|
26 | })
|
---|
27 | )
|
---|
28 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.