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

Function createCommit

repository_test.go:85–113  ·  view source on GitHub ↗
(c *C, r *Repository)

Source from the content-addressed store, hash-verified

83}
84
85func createCommit(c *C, r *Repository) plumbing.Hash {
86 // Create a commit so there is a HEAD to check
87 wt, err := r.Worktree()
88 c.Assert(err, IsNil)
89
90 rm, err := wt.Filesystem.Create("foo.txt")
91 c.Assert(err, IsNil)
92
93 _, err = rm.Write([]byte("foo text"))
94 c.Assert(err, IsNil)
95
96 _, err = wt.Add("foo.txt")
97 c.Assert(err, IsNil)
98
99 author := object.Signature{
100 Name: "go-git",
101 Email: "go-git@fake.local",
102 When: time.Now(),
103 }
104
105 h, err := wt.Commit("test commit message", &CommitOptions{
106 All: true,
107 Author: &author,
108 Committer: &author,
109 AllowEmptyCommits: true,
110 })
111 c.Assert(err, IsNil)
112 return h
113}
114
115func (s *RepositorySuite) TestInitNonStandardDotGit(c *C) {
116 dir := c.MkDir()

Callers 5

TestInitMethod · 0.85
TestInitWithOptionsMethod · 0.85
TestMergeFFMethod · 0.85
TestMergeFF_InvalidMethod · 0.85

Calls 5

WorktreeMethod · 0.80
CommitMethod · 0.65
CreateMethod · 0.45
WriteMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…