상속: IDisposable
예제 #1
0
 public void AdvertiseUploadPack(Stream output)
 {
     using (var repository = GetRepository()) {
         var pack = new UploadPack(repository);
         pack.sendAdvertisedRefs(new RefAdvertiser.PacketLineOutRefAdvertiser(new PacketLineOut(output)));
     }
 }
예제 #2
0
            public override void Execute(DaemonClient client, Repository db)
            {
                var    rp     = new UploadPack(db);
                Stream stream = client.Stream;

                rp.Upload(stream, null, null);
            }
예제 #3
0
		public void Upload(Stream inputStream, Stream outputStream) {
			using (var repository = GetRepository()) {
				using (var pack = new UploadPack(repository)) {
					pack.setBiDirectionalPipe(false);
					pack.Upload(inputStream, outputStream, outputStream);
				}
			}
		}
예제 #4
0
 public ActionResult UploadPack(string project)
 {
     return ExecuteRpc(project, Rpc.UploadPack, repository => {
         using (var pack = new UploadPack(repository)) {
             pack.setBiDirectionalPipe(false);
             pack.Upload(Request.InputStream, Response.OutputStream, Response.OutputStream);
         }
     });
 }
예제 #5
0
        public void UploadPack(string project)
        {
            Response.ContentType = "application/x-git-upload-pack-result";
            WriteNoCache();

            using (var repository = repositories.GetRepository(project))
            using (var pack = new UploadPack(repository)) {
                pack.setBiDirectionalPipe(false);
                pack.Upload(Request.InputStream, Response.OutputStream, Response.OutputStream);
            }
        }
예제 #6
0
        private ActionResult GetInfoRefs(String project, String service)
        {
            Response.StatusCode = 200;

            Response.ContentType = String.Format("application/x-{0}-advertisement", service);
            SetNoCache();
            Response.Write(FormatMessage(String.Format("# service={0}\n", service)));
            Response.Write(FlushMessage());

            var directory = GetDirectoryInfo(project);
            if (GitSharp.Repository.IsValid(directory.FullName, true))
            {
                using (var repository = new GitSharp.Repository(directory.FullName))
                {
                    if (String.Equals("git-receive-pack", service, StringComparison.InvariantCultureIgnoreCase))
                    {
                        using (var pack = new ReceivePack(repository))
                        {
                            pack.SendAdvertisedRefs(new RefAdvertiser.PacketLineOutRefAdvertiser(new PacketLineOut(Response.OutputStream)));
                        }

                    }
                    else if (String.Equals("git-upload-pack", service, StringComparison.InvariantCultureIgnoreCase))
                    {
                        using (var pack = new UploadPack(repository))
                        {
                            pack.SendAdvertisedRefs(new RefAdvertiser.PacketLineOutRefAdvertiser(new PacketLineOut(Response.OutputStream)));
                        }
                    }
                }

                return new EmptyResult();
            }
            else
            {
                return new HttpNotFoundResult();
            }
        }
예제 #7
0
        private ActionResult ExecuteUploadPack(string project)
        {
            Response.ContentType = "application/x-git-upload-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 UploadPack(repository))
                {
                    pack.setBiDirectionalPipe(false);
                    pack.Upload(GetInputStream(), Response.OutputStream, Response.OutputStream);
                }

                return new EmptyResult();
            }
            else
            {
                return new HttpNotFoundResult();
            }
        }
예제 #8
0
파일: Daemon.cs 프로젝트: dev218/GitSharp
			public override void Execute(DaemonClient client, Repository db)
			{
				var rp = new UploadPack(db);
				Stream stream = client.Stream;
				rp.Upload(stream, null, null);
			}
예제 #9
0
            public InternalLocalFetchConnection( TransportLocal transport)
                : base(transport)
            {
                Repository dst;
                try
                {
                    dst = new Repository(transport.remoteGitDir);
                }
                catch (IOException)
                {
                    throw new TransportException(uri, "Not a Git directory");
                }

                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
                        {
                            UploadPack rp = new UploadPack(dst);
                            rp.Upload(out_r, in_w, null);
                        }
                        catch (IOException ex)
                        {
                            // Client side of the pipes should report the problem.
                            ex.printStackTrace();
                        }
                        catch (Exception ex)
                        {
                            // Clients side will notice we went away, and report.
                            ex.printStackTrace();
                        }
                        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-Upload-Pack";
                worker.Start();

                init(in_r, out_w);
                readAdvertisedRefs();
            }
예제 #10
0
            public InternalLocalFetchConnection(TransportLocal transport)
                : base(transport)
            {
                Repository dst;

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

                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
                    {
                        UploadPack rp = new UploadPack(dst);
                        rp.Upload(out_r, in_w, null);
                    }
                    catch (IOException ex)
                    {
                        // Client side of the pipes should report the problem.
                        ex.printStackTrace();
                    }
                    catch (Exception ex)
                    {
                        // Clients side will notice we went away, and report.
                        ex.printStackTrace();
                    }
                    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-Upload-Pack";
                worker.Start();

                init(in_r, out_w);
                readAdvertisedRefs();
            }
예제 #11
0
 private static void HandleUploadPackPost(HttpContext context, GitRoute route)
 {
     context.Response.ContentType = "application/x-git-upload-pack-result";
     var pack = new UploadPack(route.Repository);
     pack.setBiDirectionalPipe(false);
     pack.Upload(context.Request.InputStream, context.Response.OutputStream, context.Response.OutputStream);
 }
예제 #12
0
        private static void HandleInfoRefsGet(HttpContext context, GitRoute route)
        {
            var gitService = context.Request.QueryString["service"];

            if (string.IsNullOrWhiteSpace(gitService) || !gitService.StartsWith("git-"))
            {
                SendFile(context, route, "text/plain; charset=utf-8");
            }
            else
            {
                var service = gitService.Substring(4);
                context.Response.ContentType = string.Format("application/x-git-{0}-advertisement", service);
                context.Response.Write(GitString("# service=git-" + service + "\n"));
                context.Response.Write("0000");

                if (service == "upload-pack")
                {
                    var pack = new UploadPack(route.Repository);
                    pack.sendAdvertisedRefs(new RefAdvertiser.PacketLineOutRefAdvertiser(new PacketLineOut(context.Response.OutputStream)));
                }
                else if (service == "receive-pack")
                {
                    VerifyAccess(context);
                    var pack = new ReceivePack(route.Repository);
                    pack.SendAdvertisedRefs(new RefAdvertiser.PacketLineOutRefAdvertiser(new PacketLineOut(context.Response.OutputStream)));
                }
            }
        }