MCPcopy Create free account
hub / github.com/OpenCSGs/csghub-server / getFileRaw

Method getFileRaw

component/callback/git_callback.go:351–375  ·  view source on GitHub ↗
(repoType, namespace, repoName, ref, fileName string)

Source from the content-addressed store, hash-verified

349}
350
351func (c *GitCallbackComponent) getFileRaw(repoType, namespace, repoName, ref, fileName string) (string, error) {
352 var (
353 content string
354 err error
355 )
356 repoType = strings.TrimRight(repoType, "s")
357 getFileRawReq := gitserver.GetRepoInfoByPathReq{
358 Namespace: namespace,
359 Name: repoName,
360 Ref: ref,
361 Path: fileName,
362 RepoType: types.RepositoryType(repoType),
363 }
364 content, err = c.gs.GetRepoFileRaw(context.Background(), getFileRawReq)
365 if err != nil {
366 slog.Error("failed to get file content", slog.String("namespace", namespace),
367 slog.String("file", fileName), slog.String("repo", repoName), slog.String("ref", ref),
368 slog.Any("error", err))
369 return "", fmt.Errorf("failed to get file content,cause: %w", err)
370 }
371 slog.Debug("get file content success", slog.String("repoType", repoType), slog.String("namespace", namespace),
372 slog.String("file", fileName), slog.String("repo", repoName), slog.String("ref", ref))
373
374 return content, nil
375}
376
377func (c *GitCallbackComponent) checkFileContent(ctx context.Context, repoType, namespace, repoName, content string) (bool, error) {
378 ok, err := c.checkText(ctx, content)

Callers 2

modifyFilesMethod · 0.95
addFilesMethod · 0.95

Calls 3

RepositoryTypeTypeAlias · 0.92
ErrorMethod · 0.80
GetRepoFileRawMethod · 0.65

Tested by

no test coverage detected