代码拉取完成,页面将自动刷新
同步操作将从 Gitee 极速下载/go-git 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
package git
import (
"time"
"gopkg.in/src-d/go-git.v4/plumbing"
"gopkg.in/src-d/go-git.v4/plumbing/cache"
"gopkg.in/src-d/go-git.v4/plumbing/storer"
"gopkg.in/src-d/go-git.v4/storage"
"gopkg.in/src-d/go-git.v4/storage/filesystem"
. "gopkg.in/check.v1"
"gopkg.in/src-d/go-git-fixtures.v3"
)
type PruneSuite struct {
BaseSuite
}
var _ = Suite(&PruneSuite{})
func (s *PruneSuite) testPrune(c *C, deleteTime time.Time) {
srcFs := fixtures.ByTag("unpacked").One().DotGit()
var sto storage.Storer
var err error
sto = filesystem.NewStorage(srcFs, cache.NewObjectLRUDefault())
los := sto.(storer.LooseObjectStorer)
c.Assert(los, NotNil)
count := 0
err = los.ForEachObjectHash(func(_ plumbing.Hash) error {
count++
return nil
})
c.Assert(err, IsNil)
r, err := Open(sto, srcFs)
c.Assert(err, IsNil)
c.Assert(r, NotNil)
// Remove a branch so we can prune some objects.
err = sto.RemoveReference(plumbing.ReferenceName("refs/heads/v4"))
c.Assert(err, IsNil)
err = sto.RemoveReference(plumbing.ReferenceName("refs/remotes/origin/v4"))
c.Assert(err, IsNil)
err = r.Prune(PruneOptions{
OnlyObjectsOlderThan: deleteTime,
Handler: r.DeleteObject,
})
c.Assert(err, IsNil)
newCount := 0
err = los.ForEachObjectHash(func(_ plumbing.Hash) error {
newCount++
return nil
})
c.Assert(err, IsNil)
if deleteTime.IsZero() {
c.Assert(newCount < count, Equals, true)
} else {
// Assume a delete time older than any of the objects was passed in.
c.Assert(newCount, Equals, count)
}
}
func (s *PruneSuite) TestPrune(c *C) {
s.testPrune(c, time.Time{})
}
func (s *PruneSuite) TestPruneWithNoDelete(c *C) {
s.testPrune(c, time.Unix(0, 1))
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。