Skip to content

Commit 1bf9386

Browse files
committed
adding team_for_file
1 parent d3d42b5 commit 1bf9386

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/runner.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,15 @@ pub fn team_for_file_from_codeowners(run_config: &RunConfig, file_path: &str) ->
8484
.map_err(|e| Error::Io(e.to_string()))?)
8585
}
8686

87+
pub fn team_for_file(run_config: &RunConfig, file_path: &str) -> Result<Option<Team>, Error> {
88+
let config = config_from_path(&run_config.config_path)?;
89+
use crate::ownership::for_file_fast::find_file_owners;
90+
let owners = find_file_owners(&run_config.project_root, &config, std::path::Path::new(file_path))
91+
.map_err(Error::Io)?;
92+
93+
Ok(owners.first().map(|fo| fo.team.clone()))
94+
}
95+
8796
// (imports below intentionally trimmed after refactor)
8897

8998
fn for_file_optimized(run_config: &RunConfig, file_path: &str) -> RunResult {

0 commit comments

Comments
 (0)