-33
knotserver/git/git.go
-33
knotserver/git/git.go
···
120
return g.r.CommitObject(h)
121
}
122
123
-
func (g *GitRepo) LastCommit() (*object.Commit, error) {
124
-
c, err := g.r.CommitObject(g.h)
125
-
if err != nil {
126
-
return nil, fmt.Errorf("last commit: %w", err)
127
-
}
128
-
return c, nil
129
-
}
130
-
131
func (g *GitRepo) FileContentN(path string, cap int64) ([]byte, error) {
132
c, err := g.r.CommitObject(g.h)
133
if err != nil {
···
160
}
161
162
return buf.Bytes(), nil
163
-
}
164
-
165
-
func (g *GitRepo) FileContent(path string) (string, error) {
166
-
c, err := g.r.CommitObject(g.h)
167
-
if err != nil {
168
-
return "", fmt.Errorf("commit object: %w", err)
169
-
}
170
-
171
-
tree, err := c.Tree()
172
-
if err != nil {
173
-
return "", fmt.Errorf("file tree: %w", err)
174
-
}
175
-
176
-
file, err := tree.File(path)
177
-
if err != nil {
178
-
return "", err
179
-
}
180
-
181
-
isbin, _ := file.IsBinary()
182
-
183
-
if !isbin {
184
-
return file.Contents()
185
-
} else {
186
-
return "", ErrBinaryFile
187
-
}
188
}
189
190
func (g *GitRepo) RawContent(path string) ([]byte, error) {
-4
knotserver/http_util.go
-4
knotserver/http_util.go