Ejemplo n.º 1
0
 public ActionResult ReceivePack(string project)
 {
     return ExecuteRpc(project, Rpc.ReceivePack, repository => {
         var pack = new ReceivePack(repository);
         pack.setBiDirectionalPipe(false);
         pack.receive(Request.InputStream, Response.OutputStream, Response.OutputStream);
     });
 }
Ejemplo n.º 2
0
		public void Receive(Stream inputStream, Stream outputStream) {
			using (var repository = GetRepository()) {
				var pack = new ReceivePack(repository);
				pack.setPostReceiveHook(new PostReceiveFileHook(FullPath));
				pack.setBiDirectionalPipe(false);
				pack.receive(inputStream, outputStream, outputStream);
			}
		}
 public override void Receive(Stream inputStream, Stream outputStream)
 {
     using (var repository = GetRepository())
     {
         var pack = new ReceivePack(repository);
         pack.setBiDirectionalPipe(false);
         pack.receive(inputStream, outputStream, outputStream);
     }
 }
Ejemplo n.º 4
0
        public void ReceivePack(string project)
        {
            Response.ContentType = "application/x-git-receive-pack-result";
            WriteNoCache();

            using (var repository = repositories.GetRepository(project)) {
                var pack = new ReceivePack(repository);
                pack.setBiDirectionalPipe(false);
                pack.receive(Request.InputStream, Response.OutputStream, Response.OutputStream);
            }
        }
Ejemplo n.º 5
0
            public override void Execute(DaemonClient client, Repository db)
            {
                EndPoint peer = client.Peer;

                var ipEndpoint = peer as IPEndPoint;

                if (ipEndpoint == null)
                {
                    throw new InvalidOperationException("peer must be a IPEndPoint");
                }

                string       host   = Dns.GetHostEntry(ipEndpoint.Address).HostName ?? ipEndpoint.Address.ToString();
                var          rp     = new ReceivePack(db);
                Stream       stream = client.Stream;
                const string name   = "anonymous";
                string       email  = name + "@" + host;

                rp.setRefLogIdent(new PersonIdent(name, email));
                rp.receive(stream, stream, null);
            }
Ejemplo n.º 6
0
        private ActionResult ExecuteReceivePack(string project)
        {
            Response.ContentType = "application/x-git-receive-pack-result";
            SetNoCache();

            var directory = GetDirectoryInfo(project);
            if (GitSharp.Repository.IsValid(directory.FullName, true))
            {
                using (var repository = new GitSharp.Repository(directory.FullName))
                using (var pack = new ReceivePack(repository))
                {
                    pack.setBiDirectionalPipe(false);
                    pack.receive(GetInputStream(), Response.OutputStream, Response.OutputStream);
                }

                return new EmptyResult();
            }
            else
            {
                return new HttpNotFoundResult();
            }
        }
Ejemplo n.º 7
0
			public override void Execute(DaemonClient client, Repository db)
			{
				EndPoint peer = client.Peer;

				var ipEndpoint = peer as IPEndPoint;
				if (ipEndpoint == null)
				{
					throw new InvalidOperationException("peer must be a IPEndPoint");
				}

				string host = Dns.GetHostEntry(ipEndpoint.Address).HostName ?? ipEndpoint.Address.ToString();
				var rp = new ReceivePack(db);
				Stream stream = client.Stream;
				const string name = "anonymous";
				string email = name + "@" + host;
				rp.setRefLogIdent(new PersonIdent(name, email));
				rp.receive(stream, stream, null);
			}
Ejemplo n.º 8
0
            public InternalLocalPushConnection(TransportLocal transport)
                : base(transport)
            {
                Repository dst;
                try
                {
                    dst = new Repository(transport.remoteGitDir);
                }
                catch (IOException)
                {
                    throw new TransportException(uri, "Not a Git directory");
                }

                PipedInputStream in_r;
                PipedOutputStream in_w;

                PipedInputStream out_r;
                PipedOutputStream out_w;
                try
                {
                    in_r = new PipedInputStream();
                    in_w = new PipedOutputStream(in_r);

                    out_r = new PipedInputStream();
                    out_w = new PipedOutputStream(out_r);
                }
                catch (IOException ex)
                {
                    dst.Close();
                    throw new TransportException(uri, "Cannot connect pipes", ex);
                }

                worker = new Thread(() =>
                {
                    try
                    {
                        ReceivePack rp = new ReceivePack(dst);
                        rp.receive(out_r, in_w, null);
                    }
                    catch (IOException)
                    {
                        // Client side of the pipes should report the problem.
                    }
                    catch (Exception)
                    {
                        // Clients side will notice we went away, and report.
                    }
                    finally
                    {
                        try
                        {
                            out_r.close();
                        }
                        catch (IOException)
                        {
                            // Ignore close failure, we probably crashed above.
                        }

                        try
                        {
                            in_w.close();
                        }
                        catch (IOException)
                        {
                            // Ignore close failure, we probably crashed above.
                        }

                        dst.Close();
                    }
                });
                worker.Name = "JGit-Receive-Pack";
                worker.Start();

                init(in_r, out_w);
                readAdvertisedRefs();
            }
Ejemplo n.º 9
0
            public InternalLocalPushConnection(TransportLocal transport)
                : base(transport)
            {
                Repository dst;

                try
                {
                    dst = new Repository(transport.remoteGitDir);
                }
                catch (IOException)
                {
                    throw new TransportException(uri, "Not a Git directory");
                }

                PipedInputStream  in_r;
                PipedOutputStream in_w;

                PipedInputStream  out_r;
                PipedOutputStream out_w;

                try
                {
                    in_r = new PipedInputStream();
                    in_w = new PipedOutputStream(in_r);

                    out_r = new PipedInputStream();
                    out_w = new PipedOutputStream(out_r);
                }
                catch (IOException ex)
                {
                    dst.Close();
                    throw new TransportException(uri, "Cannot connect pipes", ex);
                }

                worker = new Thread(() =>
                {
                    try
                    {
                        ReceivePack rp = new ReceivePack(dst);
                        rp.receive(out_r, in_w, null);
                    }
                    catch (IOException)
                    {
                        // Client side of the pipes should report the problem.
                    }
                    catch (Exception)
                    {
                        // Clients side will notice we went away, and report.
                    }
                    finally
                    {
                        try
                        {
                            out_r.close();
                        }
                        catch (IOException)
                        {
                            // Ignore close failure, we probably crashed above.
                        }

                        try
                        {
                            in_w.close();
                        }
                        catch (IOException)
                        {
                            // Ignore close failure, we probably crashed above.
                        }

                        dst.Close();
                    }
                });
                worker.Name = "JGit-Receive-Pack";
                worker.Start();

                init(in_r, out_w);
                readAdvertisedRefs();
            }
Ejemplo n.º 10
0
 private static void HandleReceivePackPost(HttpContext context, GitRoute route)
 {
     VerifyAccess(context);
     context.Response.ContentType = "application/x-git-receive-pack-result";
     var pack = new ReceivePack(route.Repository);
     pack.setBiDirectionalPipe(false);
     pack.receive(context.Request.InputStream, context.Response.OutputStream, context.Response.OutputStream);
 }
Ejemplo n.º 11
0
        public void Receive(Stream inputStream, Stream outputStream)
        {
            using (var repository = GetRepository()) {
                var pack = new ReceivePack(repository);
                pack.setBiDirectionalPipe(false);

                if (PostRecieveHook != null) {
                    pack.setPostReceiveHook(PostRecieveHook);
                }

                pack.receive(inputStream, outputStream, outputStream);
            }
        }