Increase askpass timeout for git operations (#42946)

Bhuminjay Soni created

Closes #29903

Release Notes:

- Increased timeout from 17->300 & improved the error message.

---------

Signed-off-by: 11happy <soni5happy@gmail.com>
Signed-off-by: 11happy <bhuminjaysoni@gmail.com>

Change summary

crates/git/src/git.rs           | 3 +++
crates/project/src/git_store.rs | 2 ++
crates/proto/proto/git.proto    | 1 +
3 files changed, 6 insertions(+)

Detailed changes

crates/git/src/git.rs 🔗

@@ -232,12 +232,14 @@ impl From<Oid> for usize {
 #[derive(Copy, Clone, Debug)]
 pub enum RunHook {
     PreCommit,
+    PrePush,
 }
 
 impl RunHook {
     pub fn as_str(&self) -> &str {
         match self {
             Self::PreCommit => "pre-commit",
+            Self::PrePush => "pre-push",
         }
     }
 
@@ -248,6 +250,7 @@ impl RunHook {
     pub fn from_proto(value: i32) -> Option<Self> {
         match value {
             0 => Some(Self::PreCommit),
+            1 => Some(Self::PrePush),
             _ => None,
         }
     }

crates/project/src/git_store.rs 🔗

@@ -4648,9 +4648,11 @@ impl Repository {
             });
 
         let this = cx.weak_entity();
+        let rx = self.run_hook(RunHook::PrePush, cx);
         self.send_job(
             Some(format!("git push {} {} {}", args, remote, branch).into()),
             move |git_repo, mut cx| async move {
+                rx.await??;
                 match git_repo {
                     RepositoryState::Local(LocalRepositoryState {
                         backend,

crates/proto/proto/git.proto 🔗

@@ -565,6 +565,7 @@ message GitCreateWorktree {
 message RunGitHook {
     enum GitHook {
         PRE_COMMIT = 0;
+        PRE_PUSH = 1;
     }
 
     uint64 project_id = 1;