MCPcopy Create free account
hub / github.com/github/gh-aw / readConfiguredTargetRepo

Function readConfiguredTargetRepo

actions/setup/js/apply_samples.cjs:265–289  ·  view source on GitHub ↗

* Read the configured `target-repo` for a given safe-output tool from the * safe-outputs config file (GH_AW_SAFE_OUTPUTS_CONFIG_PATH). Returns an empty * string when no config is available or no target-repo is configured. * @param {string} tool * @returns {string}

(tool)

Source from the content-addressed store, hash-verified

263 * @returns {string}
264 */
265function readConfiguredTargetRepo(tool) {
266 const configPath = process.env.GH_AW_SAFE_OUTPUTS_CONFIG_PATH;
267 if (!configPath || !configPath.trim()) {
268 return "";
269 }
270
271 const toolKey = typeof tool === "string" ? tool.replace(/-/g, "_") : "";
272
273 try {
274 const raw = fs.readFileSync(configPath, "utf8");
275 const parsed = JSON.parse(raw);
276
277 // Mirror safe_outputs_config.cjs behavior: normalize top-level keys by replacing '-' with '_'.
278 const config = parsed && typeof parsed === "object" ? Object.fromEntries(Object.entries(parsed).map(([k, v]) => [String(k).replace(/-/g, "_"), v])) : {};
279
280 const toolConfig = toolKey && config && typeof config === "object" ? config[toolKey] : null;
281 const target = toolConfig && typeof toolConfig === "object" ? toolConfig["target-repo"] || toolConfig["target_repo"] : null;
282 if (typeof target === "string") {
283 return target.trim();
284 }
285 } catch (err) {
286 core.debug(`apply_samples: could not read target-repo from ${configPath}: ${getErrorMessage(err)}`);
287 }
288 return "";
289}
290
291/**
292 * Resolve the on-disk working directory in which a sample's patch should be

Callers 2

derivePrHeadRefFunction · 0.85
resolvePatchWorkspaceFunction · 0.85

Calls 2

getErrorMessageFunction · 0.70
parseMethod · 0.45

Tested by

no test coverage detected