Allow configuring custom git hosting providers in project settings (#31929)

Closes #29229

Release Notes:

- Extended the support for configuring custom git hosting providers to
cover project settings in addition to global settings.

---------

Co-authored-by: Anthony Eid <hello@anthonyeid.me>
This commit is contained in:
Cole Miller 2025-06-03 12:23:01 -04:00 committed by GitHub
parent 203754d0db
commit 1307b81721
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 138 additions and 20 deletions

View file

@ -250,6 +250,7 @@ trait AnySettingValue: 'static + Send + Sync {
cx: &mut App,
) -> Result<Box<dyn Any>>;
fn value_for_path(&self, path: Option<SettingsLocation>) -> &dyn Any;
fn all_local_values(&self) -> Vec<(WorktreeId, Arc<Path>, &dyn Any)>;
fn set_global_value(&mut self, value: Box<dyn Any>);
fn set_local_value(&mut self, root_id: WorktreeId, path: Arc<Path>, value: Box<dyn Any>);
fn json_schema(
@ -376,6 +377,24 @@ impl SettingsStore {
.expect("no default value for setting type")
}
/// Get all values from project specific settings
pub fn get_all_locals<T: Settings>(&self) -> Vec<(WorktreeId, Arc<Path>, &T)> {
self.setting_values
.get(&TypeId::of::<T>())
.unwrap_or_else(|| panic!("unregistered setting type {}", type_name::<T>()))
.all_local_values()
.into_iter()
.map(|(id, path, any)| {
(
id,
path,
any.downcast_ref::<T>()
.expect("wrong value type for setting"),
)
})
.collect()
}
/// Override the global value for a setting.
///
/// The given value will be overwritten if the user settings file changes.
@ -1235,6 +1254,13 @@ impl<T: Settings> AnySettingValue for SettingValue<T> {
(key, value)
}
fn all_local_values(&self) -> Vec<(WorktreeId, Arc<Path>, &dyn Any)> {
self.local_values
.iter()
.map(|(id, path, value)| (*id, path.clone(), value as _))
.collect()
}
fn value_for_path(&self, path: Option<SettingsLocation>) -> &dyn Any {
if let Some(SettingsLocation { worktree_id, path }) = path {
for (settings_root_id, settings_path, value) in self.local_values.iter().rev() {