コード例 #1
0
ファイル: Repository.cs プロジェクト: hafstrom/git-dot-aspx
 public void AdvertiseReceivePack(Stream output)
 {
     using (var repository = GetRepository()) {
         var pack = new ReceivePack(repository);
         pack.SendAdvertisedRefs(new RefAdvertiser.PacketLineOutRefAdvertiser(new PacketLineOut(output)));
     }
 }
コード例 #2
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();
            }
        }
コード例 #3
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)));
                }
            }
        }