Git - post-receive hook not working on remote windows server

后端 未结 2 1056
庸人自扰
庸人自扰 2021-01-23 05:49

I\'m trying to get a git post-receive hook working on Windows.

I\'m using Git 1.7.9 (Msysgit) and have a repo locally and a bare repo on a remote server. I can fetch, co

2条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-23 06:09

    When using msysgit on the server and pushing via a file share hooks work without problem now. Maybe this was fixed in mysysgit since the answer was written. I didn't look into it.

    I also noticed that the original question stated git dot aspx and Bonobo were being used which use GitSharp.dll. This would mean the application is not shelling out to the git.exe and hooks would not be handled the same way.

    For example, the GitSharp.dll used in git dot aspx has it's own hook post-receive hook implementation which could be performed in C#:

    public void Receive(Stream inputStream, Stream outputStream) 
    {
        using (var repository = GetRepository()) 
        {
            var pack = new ReceivePack(repository);
            pack.setBiDirectionalPipe(false);
    
            //setup post receive hook here
            pack.setPostReceiveHook(new PostRecieveHook());
    
            pack.receive(inputStream, outputStream, outputStream);
         }
    }
    
    
    public class PostRecieveHook : IPostReceiveHook 
    {
        public void OnPostReceive(ReceivePack rp, ICollection commands) 
        {
            //Do PostRecieve Hook Work Here
        }
    }
    

    I hope to help others with confusion between libraries that are implementations of Git and applications that call out to the actual git.exe.

提交回复
热议问题