代码拉取完成,页面将自动刷新
同步操作将从 Gitee 极速下载/go-git 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
package git
import (
"errors"
"time"
"gopkg.in/src-d/go-git.v4/plumbing"
"gopkg.in/src-d/go-git.v4/plumbing/storer"
)
type PruneHandler func(unreferencedObjectHash plumbing.Hash) error
type PruneOptions struct {
// OnlyObjectsOlderThan if set to non-zero value
// selects only objects older than the time provided.
OnlyObjectsOlderThan time.Time
// Handler is called on matching objects
Handler PruneHandler
}
var ErrLooseObjectsNotSupported = errors.New("Loose objects not supported")
// DeleteObject deletes an object from a repository.
// The type conveniently matches PruneHandler.
func (r *Repository) DeleteObject(hash plumbing.Hash) error {
los, ok := r.Storer.(storer.LooseObjectStorer)
if !ok {
return ErrLooseObjectsNotSupported
}
return los.DeleteLooseObject(hash)
}
func (r *Repository) Prune(opt PruneOptions) error {
los, ok := r.Storer.(storer.LooseObjectStorer)
if !ok {
return ErrLooseObjectsNotSupported
}
pw := newObjectWalker(r.Storer)
err := pw.walkAllRefs()
if err != nil {
return err
}
// Now walk all (loose) objects in storage.
return los.ForEachObjectHash(func(hash plumbing.Hash) error {
// Get out if we have seen this object.
if pw.isSeen(hash) {
return nil
}
// Otherwise it is a candidate for pruning.
// Check out for too new objects next.
if !opt.OnlyObjectsOlderThan.IsZero() {
// Errors here are non-fatal. The object may be e.g. packed.
// Or concurrently deleted. Skip such objects.
t, err := los.LooseObjectTime(hash)
if err != nil {
return nil
}
// Skip too new objects.
if !t.Before(opt.OnlyObjectsOlderThan) {
return nil
}
}
return opt.Handler(hash)
})
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。