Skip to content

Commit cfb8e9a

Browse files
committed
repo: add RepoFsck
1 parent 0ea3dcb commit cfb8e9a

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

repo.go

+15-3
Original file line numberDiff line numberDiff line change
@@ -527,18 +527,30 @@ func (r *Repository) CountObjects(opts ...CountObjectsOptions) (*CountObject, er
527527
// FsckOptions contains optional arguments for verifying the objects.
528528
// Docs: https://git-scm.com/docs/git-fsck
529529
type FsckOptions struct {
530+
// The additional arguments to be applied.
531+
Args []string
530532
// The timeout duration before giving up for each shell command execution.
531533
// The default timeout duration will be used when not supplied.
532534
Timeout time.Duration
533535
}
534536

535-
// Fsck verifies the connectivity and validity of the objects in the database for the repository.
536-
func (r *Repository) Fsck(opts ...FsckOptions) error {
537+
// RepoFsck verifies the connectivity and validity of the objects in the database for the
538+
// repository in given path.
539+
func RepoFsck(repoPath string, opts ...FsckOptions) error {
537540
var opt FsckOptions
538541
if len(opts) > 0 {
539542
opt = opts[0]
540543
}
541544

542-
_, err := NewCommand("fsck").RunInDirWithTimeout(opt.Timeout, r.path)
545+
cmd := NewCommand("fsck")
546+
if len(opt.Args) > 0 {
547+
cmd.AddArgs(opt.Args...)
548+
}
549+
_, err := cmd.RunInDirWithTimeout(opt.Timeout, repoPath)
543550
return err
544551
}
552+
553+
// Fsck verifies the connectivity and validity of the objects in the database for the repository.
554+
func (r *Repository) Fsck(opts ...FsckOptions) error {
555+
return RepoFsck(r.path, opts...)
556+
}

0 commit comments

Comments
 (0)