Only bother trying to fetch if we need to
This commit is contained in:
parent
8872e17f93
commit
6f1d00097b
1 changed files with 11 additions and 3 deletions
|
@ -147,12 +147,20 @@ func (s *server) updateBase() error {
|
||||||
return runGitCommand(s.matrixDocCloneURL, []string{"fetch"})
|
return runGitCommand(s.matrixDocCloneURL, []string{"fetch"})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *server) knowsAbout(sha string) bool {
|
||||||
|
s.mu.Lock()
|
||||||
|
defer s.mu.Unlock()
|
||||||
|
return runGitCommand(s.matrixDocCloneURL, []string{"cat-file", "-e", sha + "^{commit}"}) == nil
|
||||||
|
}
|
||||||
|
|
||||||
// generateAt generates spec from repo at sha.
|
// generateAt generates spec from repo at sha.
|
||||||
// Returns the path where the generation was done.
|
// Returns the path where the generation was done.
|
||||||
func (s *server) generateAt(sha string) (dst string, err error) {
|
func (s *server) generateAt(sha string) (dst string, err error) {
|
||||||
err = s.updateBase()
|
if !s.knowsAbout(sha) {
|
||||||
if err != nil {
|
err = s.updateBase()
|
||||||
return
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
s.mu.Lock()
|
s.mu.Lock()
|
||||||
dst, err = gitClone(s.matrixDocCloneURL, true)
|
dst, err = gitClone(s.matrixDocCloneURL, true)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue