Merge pull request 'log concise repo names in lfs doctor' (#5456) from kwonunn/fix-lfs-log-output into forgejo

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/5456
Reviewed-by: Otto <otto@codeberg.org>
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
This commit is contained in:
Gusted 2024-10-04 12:44:18 +00:00
commit 14b6f26aab

View file

@ -52,21 +52,21 @@ func GarbageCollectLFSMetaObjects(ctx context.Context, opts GarbageCollectLFSMet
// GarbageCollectLFSMetaObjectsForRepo garbage collects LFS objects for a specific repository // GarbageCollectLFSMetaObjectsForRepo garbage collects LFS objects for a specific repository
func GarbageCollectLFSMetaObjectsForRepo(ctx context.Context, repo *repo_model.Repository, opts GarbageCollectLFSMetaObjectsOptions) error { func GarbageCollectLFSMetaObjectsForRepo(ctx context.Context, repo *repo_model.Repository, opts GarbageCollectLFSMetaObjectsOptions) error {
opts.LogDetail("Checking %-v", repo) opts.LogDetail("Checking %s", repo.FullName())
total, orphaned, collected, deleted := int64(0), 0, 0, 0 total, orphaned, collected, deleted := int64(0), 0, 0, 0
defer func() { defer func() {
if orphaned == 0 { if orphaned == 0 {
opts.LogDetail("Found %d total LFSMetaObjects in %-v", total, repo) opts.LogDetail("Found %d total LFSMetaObjects in %s", total, repo.FullName())
} else if !opts.AutoFix { } else if !opts.AutoFix {
opts.LogDetail("Found %d/%d orphaned LFSMetaObjects in %-v", orphaned, total, repo) opts.LogDetail("Found %d/%d orphaned LFSMetaObjects in %s", orphaned, total, repo.FullName())
} else { } else {
opts.LogDetail("Collected %d/%d orphaned/%d total LFSMetaObjects in %-v. %d removed from storage.", collected, orphaned, total, repo, deleted) opts.LogDetail("Collected %d/%d orphaned/%d total LFSMetaObjects in %s. %d removed from storage.", collected, orphaned, total, repo.FullName(), deleted)
} }
}() }()
gitRepo, err := gitrepo.OpenRepository(ctx, repo) gitRepo, err := gitrepo.OpenRepository(ctx, repo)
if err != nil { if err != nil {
log.Error("Unable to open git repository %-v: %v", repo, err) log.Error("Unable to open git repository %s: %v", repo.FullName(), err)
return err return err
} }
defer gitRepo.Close() defer gitRepo.Close()