MCPcopy
hub / github.com/harness/harness / FileViewDelete

Method FileViewDelete

app/api/controller/pullreq/file_view_delete.go:27–54  ·  view source on GitHub ↗

FileViewDelete removes a file from being marked as viewed.

(
	ctx context.Context,
	session *auth.Session,
	repoRef string,
	prNum int64,
	filePath string,
)

Source from the content-addressed store, hash-verified

25
26// FileViewDelete removes a file from being marked as viewed.
27func (c *Controller) FileViewDelete(
28 ctx context.Context,
29 session *auth.Session,
30 repoRef string,
31 prNum int64,
32 filePath string,
33) error {
34 repo, err := c.getRepoCheckAccess(ctx, session, repoRef, enum.PermissionRepoReview)
35 if err != nil {
36 return fmt.Errorf("failed to acquire access to repo: %w", err)
37 }
38
39 pr, err := c.pullreqStore.FindByNumber(ctx, repo.ID, prNum)
40 if err != nil {
41 return fmt.Errorf("failed to find pull request by number: %w", err)
42 }
43
44 if filePath == "" {
45 return usererror.BadRequest("file path can't be empty")
46 }
47
48 err = c.fileViewStore.DeleteByFileForPrincipal(ctx, pr.ID, session.Principal.ID, filePath)
49 if err != nil {
50 return fmt.Errorf("failed to delete file view entry in db: %w", err)
51 }
52
53 return nil
54}

Callers 1

HandleFileViewDeleteFunction · 0.80

Calls 5

getRepoCheckAccessMethod · 0.95
BadRequestFunction · 0.92
FindByNumberMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected