File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -150,6 +150,14 @@ pub fn hooks_pre_push(
150150 scope_time ! ( "hooks_pre_push" ) ;
151151
152152 let repo = repo ( repo_path) ?;
153+ if !git2_hooks:: hook_available (
154+ & repo,
155+ None ,
156+ git2_hooks:: HOOK_PRE_PUSH ,
157+ ) ? {
158+ return Ok ( HookResult :: Ok ) ;
159+ }
160+
153161 let advertised = advertised_remote_refs ( repo_path, remote, url) ?;
154162 let updates = match push {
155163 PrePushTarget :: Branch { branch, delete } => {
Original file line number Diff line number Diff line change @@ -48,6 +48,16 @@ pub const HOOK_PRE_PUSH: &str = "pre-push";
4848
4949const HOOK_COMMIT_MSG_TEMP_FILE : & str = "COMMIT_EDITMSG" ;
5050
51+ /// Check if a given hook is present considering config/paths and optional extra paths.
52+ pub fn hook_available (
53+ repo : & Repository ,
54+ other_paths : Option < & [ & str ] > ,
55+ hook : & str ,
56+ ) -> Result < bool > {
57+ let hook = HookPaths :: new ( repo, other_paths, hook) ?;
58+ Ok ( hook. found ( ) )
59+ }
60+
5161#[ derive( Clone , Debug , PartialEq , Eq ) ]
5262pub struct PrePushRef {
5363 pub local_ref : String ,
You can’t perform that action at this time.
0 commit comments