MCPcopy Create free account
hub / github.com/alibaba/open-code-review / loadDelegateContext

Function loadDelegateContext

cmd/opencodereview/delegate_cmd.go:84–115  ·  view source on GitHub ↗
(opts delegateOptions)

Source from the content-addressed store, hash-verified

82}
83
84func loadDelegateContext(opts delegateOptions) (*delegateContext, error) {
85 cc, err := loadCommonContext(opts.repoDir, opts.rulePath, 0, opts.maxGitProcs, true)
86 if err != nil {
87 return nil, err
88 }
89 applyCLIExcludes(cc, splitPaths(opts.excludes))
90
91 // Security: reject ref-option injection.
92 reviewOpts := reviewOptions{from: opts.from, to: opts.to, commit: opts.commit}
93 if err := validateReviewRefs(cc.RepoDir, reviewOpts); err != nil {
94 return nil, err
95 }
96
97 // Resolve background from --background-file if set.
98 if opts.backgroundFile != "" {
99 bgPath := resolveBackgroundFilePath(cc.RepoDir, opts.backgroundFile)
100 fileBackground, err := loadBackgroundFile(bgPath)
101 if err != nil {
102 return nil, err
103 }
104 opts.background = mergeBackground(opts.background, fileBackground)
105 }
106
107 // Auto-fill background from commit message when reviewing a single commit.
108 if opts.commit != "" && opts.background == "" {
109 if msg, err := getCommitMessage(cc.RepoDir, opts.commit); err == nil && msg != "" {
110 opts.background = msg
111 }
112 }
113
114 return &delegateContext{cc: cc, opts: opts}, nil
115}
116
117// preview runs the agent's file-selection logic and returns the preview result.
118func (dc *delegateContext) preview(ctx context.Context) (*agent.DiffPreview, error) {

Callers 2

executeDelegatePreviewFunction · 0.85
executeDelegateRuleFunction · 0.85

Calls 8

loadCommonContextFunction · 0.85
applyCLIExcludesFunction · 0.85
splitPathsFunction · 0.85
validateReviewRefsFunction · 0.85
loadBackgroundFileFunction · 0.85
mergeBackgroundFunction · 0.85
getCommitMessageFunction · 0.85

Tested by

no test coverage detected