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

Function loadDelegateContext

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

Source from the content-addressed store, hash-verified

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

Calls 8

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