(repoType, namespace, repoName, ref, fileName string)
| 349 | } |
| 350 | |
| 351 | func (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 | |
| 377 | func (c *GitCallbackComponent) checkFileContent(ctx context.Context, repoType, namespace, repoName, content string) (bool, error) { |
| 378 | ok, err := c.checkText(ctx, content) |
no test coverage detected