Skip to content

Commit 936a7cb

Browse files
committed
provide same creds to hooks call as to push
1 parent ad7c511 commit 936a7cb

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

asyncgit/src/sync/hooks.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ pub fn advertised_remote_refs(
4848
repo_path: &RepoPath,
4949
remote: Option<&str>,
5050
url: &str,
51+
basic_credential: Option<crate::sync::cred::BasicAuthCredential>,
5152
) -> Result<HashMap<String, Oid>> {
5253
let repo = repo(repo_path)?;
5354
let mut remote_handle = if let Some(name) = remote {
@@ -56,7 +57,7 @@ pub fn advertised_remote_refs(
5657
repo.remote_anonymous(url)?
5758
};
5859

59-
let callbacks = Callbacks::new(None, None);
60+
let callbacks = Callbacks::new(None, basic_credential);
6061
let conn = remote_handle.connect_auth(
6162
Direction::Push,
6263
Some(callbacks.callbacks()),
@@ -146,6 +147,7 @@ pub fn hooks_pre_push(
146147
remote: Option<&str>,
147148
url: &str,
148149
push: &PrePushTarget<'_>,
150+
basic_credential: Option<crate::sync::cred::BasicAuthCredential>,
149151
) -> Result<HookResult> {
150152
scope_time!("hooks_pre_push");
151153

@@ -158,7 +160,12 @@ pub fn hooks_pre_push(
158160
return Ok(HookResult::Ok);
159161
}
160162

161-
let advertised = advertised_remote_refs(repo_path, remote, url)?;
163+
let advertised = advertised_remote_refs(
164+
repo_path,
165+
remote,
166+
url,
167+
basic_credential,
168+
)?;
162169
let updates = match push {
163170
PrePushTarget::Branch { branch, delete } => {
164171
let remote_ref = branch_push_destination_ref(

asyncgit/src/sync/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ pub use git2::BranchType;
6868
pub use hooks::{
6969
advertised_remote_refs, hooks_commit_msg, hooks_post_commit,
7070
hooks_pre_commit, hooks_pre_push, hooks_prepare_commit_msg,
71-
HookResult, PrePushRef, PrePushTarget, PrepareCommitMsgSource,
71+
HookResult, PrePushTarget, PrepareCommitMsgSource,
7272
};
7373
pub use hunks::{reset_hunk, stage_hunk, unstage_hunk};
7474
pub use ignore::add_to_ignore;

src/popups/push.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ impl PushPopup {
171171
branch: &self.branch,
172172
delete: self.modifier.delete(),
173173
},
174+
cred.clone(),
174175
)? {
175176
log::error!("pre-push hook failed: {e}");
176177
self.queue.push(InternalEvent::ShowErrorMsg(format!(

src/popups/push_tags.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ impl PushTagsPopup {
110110
Some(&remote),
111111
&remote_url,
112112
&asyncgit::sync::PrePushTarget::Tags,
113+
cred.clone(),
113114
)? {
114115
log::error!("pre-push hook failed: {e}");
115116
self.queue.push(InternalEvent::ShowErrorMsg(format!(

0 commit comments

Comments
 (0)