fn changed_packages(
        &self,
        from_ref: Option<&str>,
        to_ref: Option<&str>,
        include_uncommitted: bool,
        allow_unknown_objects: bool,
        merge_base: bool,
    ) -> Result<HashMap<PackageName, PackageInclusionReason>, ResolutionError> {
        let changed_files = match self.scm.changed_files(
            self.turbo_root,
            from_ref,
            to_ref,
            include_uncommitted,
            allow_unknown_objects,
            merge_base,
        )? {
            Err(InvalidRange { from_ref, to_ref }) => {
                debug!("invalid ref range, defaulting to all packages changed");
                return Ok(self
                    .pkg_graph
                    .packages()
                    .map(|(name, _)| {
                        (
                            name.to_owned(),
                            PackageInclusionReason::All(AllPackageChangeReason::GitRefNotFound {
                                from_ref: from_ref.clone(),
                                to_ref: to_ref.clone(),
                            }),
                        )
                    })
                    .collect());
            }
            Ok(changed_files) => changed_files,
        };

        let lockfile_contents = self.get_lockfile_contents(from_ref, &changed_files);

        debug!(
            "changed files: {:?}",
            &changed_files
                .iter()
                .map(|x| x.to_string())
                .collect::<Vec<String>>()
        );

        match self
            .change_mapper
            .changed_packages(changed_files, lockfile_contents)?
        {
            PackageChanges::All(reason) => {
                debug!("all packages changed: {:?}", reason);
                Ok(self
                    .pkg_graph
                    .packages()
                    .map(|(name, _)| (name.to_owned(), PackageInclusionReason::All(reason.clone())))
                    .collect())
            }
            PackageChanges::Some(packages) => {
                debug!(
                    "{} packages changed: {:?}",
                    packages.len(),
                    packages
                        .keys()
                        .map(|x| x.name.to_string())
                        .collect::<Vec<String>>()
                );

                Ok(packages
                    .iter()
                    .map(|(package, reason)| (package.name.clone(), reason.clone()))
                    .collect())
            }
        }
    }
get the actual changed packages between two git refs
crates/turborepo-lib/src/run/scope/change_detector.rs