MCPcopy Create free account
hub / github.com/libgit2/git2go / seedTestRepoOpt

Function seedTestRepoOpt

git_test.go:95–142  ·  view source on GitHub ↗
(t *testing.T, repo *Repository, opts commitOptions)

Source from the content-addressed store, hash-verified

93}
94
95func seedTestRepoOpt(t *testing.T, repo *Repository, opts commitOptions) (*Oid, *Oid) {
96 loc, err := time.LoadLocation("Europe/Berlin")
97 checkFatal(t, err)
98 sig := &Signature{
99 Name: "Rand Om Hacker",
100 Email: "random@hacker.com",
101 When: time.Date(2013, 03, 06, 14, 30, 0, 0, loc),
102 }
103
104 idx, err := repo.Index()
105 checkFatal(t, err)
106 err = idx.AddByPath("README")
107 checkFatal(t, err)
108 err = idx.Write()
109 checkFatal(t, err)
110 treeId, err := idx.WriteTree()
111 checkFatal(t, err)
112
113 message := "This is a commit\n"
114 tree, err := repo.LookupTree(treeId)
115 checkFatal(t, err)
116 commitId, err := repo.CreateCommit("HEAD", sig, sig, message, tree)
117 checkFatal(t, err)
118
119 if opts.CommitSigningCallback != nil {
120 commit, err := repo.LookupCommit(commitId)
121 checkFatal(t, err)
122
123 signature, signatureField, err := opts.CommitSigningCallback(commit.ContentToSign())
124 checkFatal(t, err)
125
126 oid, err := commit.WithSignature(signature, signatureField)
127 checkFatal(t, err)
128 newCommit, err := repo.LookupCommit(oid)
129 checkFatal(t, err)
130 head, err := repo.Head()
131 checkFatal(t, err)
132 _, err = repo.References.Create(
133 head.Name(),
134 newCommit.Id(),
135 true,
136 "repoint to signed commit",
137 )
138 checkFatal(t, err)
139 }
140
141 return commitId, treeId
142}
143
144func pathInRepo(repo *Repository, name string) string {
145 return path.Join(path.Dir(path.Dir(repo.Path())), name)

Callers 2

TestRebaseGpgSignedFunction · 0.85
seedTestRepoFunction · 0.85

Calls 14

checkFatalFunction · 0.85
AddByPathMethod · 0.80
WriteTreeMethod · 0.80
LookupTreeMethod · 0.80
CreateCommitMethod · 0.80
LookupCommitMethod · 0.80
ContentToSignMethod · 0.80
WithSignatureMethod · 0.80
HeadMethod · 0.80
IndexMethod · 0.45
WriteMethod · 0.45
CreateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…