MCPcopy
hub / github.com/go-git/go-git / TestFilenameNormalization

Method TestFilenameNormalization

worktree_test.go:565–642  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

563}
564
565func (s *WorktreeSuite) TestFilenameNormalization(c *C) {
566 if runtime.GOOS == "windows" {
567 c.Skip("windows paths may contain non utf-8 sequences")
568 }
569
570 url := c.MkDir()
571
572 path := fixtures.Basic().ByTag("worktree").One().Worktree().Root()
573
574 server, err := PlainClone(url, false, &CloneOptions{
575 URL: path,
576 })
577 c.Assert(err, IsNil)
578
579 filename := "페"
580
581 w, err := server.Worktree()
582 c.Assert(err, IsNil)
583
584 writeFile := func(path string) {
585 err := util.WriteFile(w.Filesystem, path, []byte("foo"), 0755)
586 c.Assert(err, IsNil)
587 }
588
589 writeFile(filename)
590 origHash, err := w.Add(filename)
591 c.Assert(err, IsNil)
592 _, err = w.Commit("foo", &CommitOptions{Author: defaultSignature()})
593 c.Assert(err, IsNil)
594
595 r, err := Clone(memory.NewStorage(), memfs.New(), &CloneOptions{
596 URL: url,
597 })
598 c.Assert(err, IsNil)
599
600 w, err = r.Worktree()
601 c.Assert(err, IsNil)
602
603 status, err := w.Status()
604 c.Assert(err, IsNil)
605 c.Assert(status.IsClean(), Equals, true)
606
607 err = w.Filesystem.Remove(filename)
608 c.Assert(err, IsNil)
609
610 modFilename := norm.NFKD.String(filename)
611 writeFile(modFilename)
612
613 _, err = w.Add(filename)
614 c.Assert(err, IsNil)
615 modHash, err := w.Add(modFilename)
616 c.Assert(err, IsNil)
617 // At this point we've got two files with the same content.
618 // Hence their hashes must be the same.
619 c.Assert(origHash == modHash, Equals, true)
620
621 status, err = w.Status()
622 c.Assert(err, IsNil)

Callers

nothing calls this directly

Calls 13

NewStorageFunction · 0.92
PlainCloneFunction · 0.85
defaultSignatureFunction · 0.85
CloneFunction · 0.85
RootMethod · 0.80
WorktreeMethod · 0.80
SkipMethod · 0.65
CommitMethod · 0.65
StringMethod · 0.65
AddMethod · 0.45
StatusMethod · 0.45
IsCleanMethod · 0.45

Tested by

no test coverage detected