Skip to content

Commit

Permalink
Mark submodules as vendored by default (#164)
Browse files Browse the repository at this point in the history
  • Loading branch information
spenserblack committed Sep 5, 2023
1 parent 48db652 commit 748cd7e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions gengo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ impl Gengo {

let mut all_results = Vec::new();
while let Some((root, repo, tree_id)) = stack.pop() {
let is_submodule = !root.is_empty();
let (state, index) = GitState::new(&repo, &tree_id)?;
let (mut results, submodule_id_by_path) = Results::from_index(root.clone(), index);

Expand All @@ -149,7 +150,7 @@ impl Gengo {
})
.collect::<HashMap<_, _>>()
});
self.analyze_index(&repo.into_sync(), &mut results, state)?;
self.analyze_index(&repo.into_sync(), &mut results, state, is_submodule)?;
all_results.push(results);

if let Some(mut submodules_by_path) = submodules {
Expand Down Expand Up @@ -179,6 +180,7 @@ impl Gengo {
repo: &gix::ThreadSafeRepository,
results: &mut Results,
state: GitState,
is_submodule: bool,
) -> Result<()> {
gix::parallel::in_parallel_with_slice(
&mut results.entries,
Expand All @@ -193,7 +195,7 @@ impl Gengo {
else {
return Ok(());
};
self.analyze_blob(path, repo, state, entry)
self.analyze_blob(path, repo, state, entry, is_submodule)
},
|| Some(std::time::Duration::from_micros(5)),
std::convert::identity,
Expand All @@ -207,6 +209,7 @@ impl Gengo {
repo: &gix::Repository,
state: &mut GitState,
result: &mut BlobEntry,
is_submodule: bool,
) -> Result<()> {
let filepath = filepath.as_ref();
let blob = repo.find_object(result.index_entry.id)?;
Expand Down Expand Up @@ -258,7 +261,7 @@ impl Gengo {
let vendored = attrs[3]
.as_ref()
.map(|info| info.assignment.state.is_set())
.unwrap_or_else(|| self.is_vendored(filepath, contents));
.unwrap_or_else(|| is_submodule || self.is_vendored(filepath, contents));

let detectable = match language.category() {
Category::Data | Category::Prose => false,
Expand Down

0 comments on commit 748cd7e

Please sign in to comment.