WIP and merge

This commit is contained in:
Anthony 2025-06-27 18:38:25 -04:00
parent 97f4406ef6
commit 1bdde8b2e4
584 changed files with 33536 additions and 17400 deletions

View file

@ -9,9 +9,7 @@ pub use crate::hosting_provider::*;
pub use crate::remote::*;
use anyhow::{Context as _, Result};
pub use git2 as libgit;
use gpui::action_with_deprecated_aliases;
use gpui::actions;
use gpui::impl_action_with_deprecated_aliases;
use gpui::{Action, actions};
pub use repository::WORK_DIRECTORY_REPO_PATH;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
@ -36,7 +34,11 @@ actions!(
ToggleStaged,
StageAndNext,
UnstageAndNext,
#[action(deprecated_aliases = ["editor::RevertSelectedHunks"])]
Restore,
// per-file
#[action(deprecated_aliases = ["editor::ToggleGitBlame"])]
Blame,
StageFile,
UnstageFile,
// repo-wide
@ -57,19 +59,17 @@ actions!(
ExpandCommitEditor,
GenerateCommitMessage,
Init,
OpenModifiedFiles,
]
);
#[derive(Clone, Debug, Default, PartialEq, Deserialize, JsonSchema)]
#[derive(Clone, Debug, Default, PartialEq, Deserialize, JsonSchema, Action)]
#[action(namespace = git, deprecated_aliases = ["editor::RevertFile"])]
pub struct RestoreFile {
#[serde(default)]
pub skip_prompt: bool,
}
impl_action_with_deprecated_aliases!(git, RestoreFile, ["editor::RevertFile"]);
action_with_deprecated_aliases!(git, Restore, ["editor::RevertSelectedHunks"]);
action_with_deprecated_aliases!(git, Blame, ["editor::ToggleGitBlame"]);
/// The length of a Git short SHA.
pub const SHORT_SHA_LENGTH: usize = 7;

View file

@ -26,8 +26,8 @@ use std::{
};
use sum_tree::MapSeekTarget;
use thiserror::Error;
use util::ResultExt;
use util::command::{new_smol_command, new_std_command};
use util::{ResultExt, paths};
use uuid::Uuid;
pub use askpass::{AskPassDelegate, AskPassResult, AskPassSession};
@ -508,6 +508,50 @@ pub struct GitRepositoryCheckpoint {
pub commit_sha: Oid,
}
#[derive(Debug)]
pub struct GitCommitter {
pub name: Option<String>,
pub email: Option<String>,
}
pub async fn get_git_committer(cx: &AsyncApp) -> GitCommitter {
if cfg!(any(feature = "test-support", test)) {
return GitCommitter {
name: None,
email: None,
};
}
let git_binary_path =
if cfg!(target_os = "macos") && option_env!("ZED_BUNDLE").as_deref() == Some("true") {
cx.update(|cx| {
cx.path_for_auxiliary_executable("git")
.context("could not find git binary path")
.log_err()
})
.ok()
.flatten()
} else {
None
};
let git = GitBinary::new(
git_binary_path.unwrap_or(PathBuf::from("git")),
paths::home_dir().clone(),
cx.background_executor().clone(),
);
cx.background_spawn(async move {
let name = git.run(["config", "--global", "user.name"]).await.log_err();
let email = git
.run(["config", "--global", "user.email"])
.await
.log_err();
GitCommitter { name, email }
})
.await
}
impl GitRepository for RealGitRepository {
fn reload_index(&self) {
if let Ok(mut index) = self.repository.lock().index() {