MCPcopy Create free account
hub / github.com/f0rr0/oliphaunt / discover_control_file

Function discover_control_file

xtask/src/extension_catalog.rs:1188–1225  ·  view source on GitHub ↗
(
    id: &str,
    sql_name: &str,
    repl_export: Option<&ReplExport>,
)

Source from the content-addressed store, hash-verified

1186}
1187
1188fn discover_control_file(
1189 id: &str,
1190 sql_name: &str,
1191 repl_export: Option<&ReplExport>,
1192) -> Option<PathBuf> {
1193 let candidates = if repl_export
1194 .map(|entry| entry.import_path.contains("/contrib/"))
1195 .unwrap_or(false)
1196 {
1197 let dashed_id = id.replace('_', "-");
1198 vec![
1199 Path::new(POSTGRES_CONTRIB)
1200 .join(id)
1201 .join(format!("{sql_name}.control")),
1202 Path::new(POSTGRES_CONTRIB)
1203 .join(id)
1204 .join(format!("{id}.control")),
1205 Path::new(POSTGRES_CONTRIB)
1206 .join(id)
1207 .join(format!("{dashed_id}.control")),
1208 Path::new(POSTGRES_CONTRIB)
1209 .join(&dashed_id)
1210 .join(format!("{sql_name}.control")),
1211 Path::new(POSTGRES_CONTRIB)
1212 .join(&dashed_id)
1213 .join(format!("{dashed_id}.control")),
1214 ]
1215 } else {
1216 vec![
1217 Path::new(&extension_source_dir_for(
1218 id,
1219 classify_source_kind(id, repl_export, None),
1220 ))
1221 .join(format!("{sql_name}.control")),
1222 ]
1223 };
1224 candidates.into_iter().find(|path| path.is_file())
1225}
1226
1227fn parse_control_file(path: &Path) -> Result<ControlMetadata> {
1228 let text = fs::read_to_string(path).with_context(|| format!("read {}", path.display()))?;

Callers 2

discover_catalogFunction · 0.85
discover_sql_nameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected