fix: correct pull for multiple repos

This commit is contained in:
2025-06-20 09:08:34 +03:00
parent 4c1f2ea90f
commit 51fdea781b
4 changed files with 46 additions and 39 deletions

View File

@ -11,7 +11,7 @@
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
<text x="33.5" y="15" fill="#010101" fill-opacity=".3">coverage</text>
<text x="33.5" y="14">coverage</text>
<text x="86" y="15" fill="#010101" fill-opacity=".3">18.8%</text>
<text x="86" y="14">18.8%</text>
<text x="86" y="15" fill="#010101" fill-opacity=".3">18.9%</text>
<text x="86" y="14">18.9%</text>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 926 B

After

Width:  |  Height:  |  Size: 926 B

View File

@ -68,33 +68,40 @@ func (rs *Repos) Pull(ctx context.Context, repos []types.Repo) error {
}
for _, repo := range repos {
urls := []string{repo.URL}
urls = append(urls, repo.Mirrors...)
var lastErr error
for i, repoURL := range urls {
if i > 0 {
slog.Info(gotext.Get("Trying mirror"), "repo", repo.Name, "mirror", repoURL)
}
err := rs.pullRepoFromURL(ctx, repoURL, repo)
if err != nil {
lastErr = err
slog.Warn(gotext.Get("Failed to pull from URL"), "repo", repo.Name, "url", repoURL, "error", err)
continue
}
// Success
return nil
err := rs.pullRepo(ctx, repo)
if err != nil {
return err
}
return fmt.Errorf("failed to pull repository %s from any URL: %w", repo.Name, lastErr)
}
return nil
}
func (rs *Repos) pullRepo(ctx context.Context, repo types.Repo) error {
urls := []string{repo.URL}
urls = append(urls, repo.Mirrors...)
var lastErr error
for i, repoURL := range urls {
if i > 0 {
slog.Info(gotext.Get("Trying mirror"), "repo", repo.Name, "mirror", repoURL)
}
err := rs.pullRepoFromURL(ctx, repoURL, repo)
if err != nil {
lastErr = err
slog.Warn(gotext.Get("Failed to pull from URL"), "repo", repo.Name, "url", repoURL, "error", err)
continue
}
// Success
return nil
}
return fmt.Errorf("failed to pull repository %s from any URL: %w", repo.Name, lastErr)
}
func readGitRepo(repoDir, repoUrl string) (*git.Repository, bool, error) {
gitDir := filepath.Join(repoDir, ".git")
if fi, err := os.Stat(gitDir); err == nil && fi.IsDir() {

View File

@ -383,27 +383,27 @@ msgstr ""
msgid "ERROR"
msgstr ""
#: internal/repos/pull.go:78
#: internal/repos/pull.go:88
msgid "Trying mirror"
msgstr ""
#: internal/repos/pull.go:84
#: internal/repos/pull.go:94
msgid "Failed to pull from URL"
msgstr ""
#: internal/repos/pull.go:151
#: internal/repos/pull.go:158
msgid "Pulling repository"
msgstr ""
#: internal/repos/pull.go:188
#: internal/repos/pull.go:195
msgid "Repository up to date"
msgstr ""
#: internal/repos/pull.go:223
#: internal/repos/pull.go:230
msgid "Git repository does not appear to be a valid ALR repo"
msgstr ""
#: internal/repos/pull.go:239
#: internal/repos/pull.go:246
msgid ""
"ALR repo's minimum ALR version is greater than the current version. Try "
"updating ALR if something doesn't work."

View File

@ -12,8 +12,8 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && "
"n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
"X-Generator: Gtranslator 48.0\n"
#: build.go:42
@ -356,8 +356,8 @@ msgid ""
"This command is deprecated and would be removed in the future, use \"%s\" "
"instead!"
msgstr ""
"Эта команда устарела и будет удалена в будущем, используйте вместо нее "
"\"%s\"!"
"Эта команда устарела и будет удалена в будущем, используйте вместо нее \"%s"
"\"!"
#: internal/db/db.go:76
msgid "Database version mismatch; resetting"
@ -397,27 +397,27 @@ msgstr "%s %s загружается — %s/с\n"
msgid "ERROR"
msgstr "ОШИБКА"
#: internal/repos/pull.go:78
#: internal/repos/pull.go:88
msgid "Trying mirror"
msgstr "Пробую зеркало"
#: internal/repos/pull.go:84
#: internal/repos/pull.go:94
msgid "Failed to pull from URL"
msgstr "Не удалось извлечь из URL"
#: internal/repos/pull.go:151
#: internal/repos/pull.go:158
msgid "Pulling repository"
msgstr "Скачивание репозитория"
#: internal/repos/pull.go:188
#: internal/repos/pull.go:195
msgid "Repository up to date"
msgstr "Репозиторий уже обновлён"
#: internal/repos/pull.go:223
#: internal/repos/pull.go:230
msgid "Git repository does not appear to be a valid ALR repo"
msgstr "Репозиторий Git не поддерживается репозиторием ALR"
#: internal/repos/pull.go:239
#: internal/repos/pull.go:246
msgid ""
"ALR repo's minimum ALR version is greater than the current version. Try "
"updating ALR if something doesn't work."