Fix issue where the git downloader re-downloads the source after updating it
ci/woodpecker/push/woodpecker Pipeline was successful Details

This commit is contained in:
Elara 2023-10-11 14:16:36 -07:00
parent c98741b8f2
commit 4218912123
2 changed files with 12 additions and 1 deletions

View File

@ -209,9 +209,10 @@ func Download(ctx context.Context, opts Options) (err error) {
}
if ok && !updated {
log.Info("Source found in cache, linked to destination").Str("source", opts.Name).Stringer("type", t).Send()
log.Info("Source found in cache and linked to destination").Str("source", opts.Name).Stringer("type", t).Send()
return nil
} else if ok {
log.Info("Source updated and linked to destination").Str("source", opts.Name).Stringer("type", t).Send()
return nil
}
} else {

View File

@ -177,6 +177,9 @@ func (GitDownloader) Update(opts Options) (bool, error) {
po.RecurseSubmodules = git.DefaultSubmoduleRecursionDepth
}
m, err := getManifest(opts.Destination)
manifestOK := err == nil
err = w.Pull(po)
if errors.Is(err, git.NoErrAlreadyUpToDate) {
return false, nil
@ -184,5 +187,12 @@ func (GitDownloader) Update(opts Options) (bool, error) {
return false, err
}
if manifestOK {
err = writeManifest(opts.Destination, m)
if err != nil {
return true, err
}
}
return true, nil
}