private void Run(ReceivePack rp, string hook) { var processStartInfo = new ProcessStartInfo { FileName = hook, UseShellExecute = false, WindowStyle = ProcessWindowStyle.Hidden, CreateNoWindow = true, RedirectStandardOutput = true, RedirectStandardError = true, RedirectStandardInput = true, WorkingDirectory = FullPath }; var appSettings = AppSettings.Current; using(var process = new Process { StartInfo = processStartInfo }) { if(!appSettings.RunHooksSilently) { process.OutputDataReceived += (d, r) => { if(!String.IsNullOrWhiteSpace(r.Data)) rp.sendMessage(r.Data); }; process.ErrorDataReceived += (d, r) => { if(!String.IsNullOrWhiteSpace(r.Data)) rp.sendError(r.Data); }; } process.Start(); process.BeginOutputReadLine(); process.BeginErrorReadLine(); foreach(var command in rp.getAllCommands()) { process.StandardInput.WriteLine(command.getOldId().Name + " " + command.getNewId().Name + " " + command.getRefName()); } process.StandardInput.Close(); process.WaitForExit((int) appSettings.HookTimeout.TotalMilliseconds); process.WaitForExit(); process.Close(); } }
public void AdvertiseReceivePack(Stream output) { using (var repository = GetRepository()) { var pack = new ReceivePack(repository); pack.SendAdvertisedRefs(new RefAdvertiser.PacketLineOutRefAdvertiser(new PacketLineOut(output))); } }
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); }); }
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); } }
public void OnPostReceive(ReceivePack rp, ICollection<ReceiveCommand> commands) { try { if (!string.IsNullOrEmpty(fogBugzApi) && commands != null && commands.Count > 0) { UpdateFogBugz(rp, commands); } } catch { } }
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); } }
public void OnPostReceive(ReceivePack rp, ICollection<ReceiveCommand> commands) { var hooksDirectory = new DirectoryInfo(Path.Combine(FullPath, "hooks")); if(!hooksDirectory.Exists) { hooksDirectory = new DirectoryInfo(Path.Combine(FullPath, ".git/hooks")); if(!hooksDirectory.Exists) return; } var hooks = hooksDirectory .GetFiles("post-receive*") .Where(hook => !hook.FullName.EndsWith(".sample")); foreach (var hook in hooks) { Run(rp, hook.FullName); } }
// To keep this simple I only look at the head commit and parse the bugzid. void UpdateFogBugz(ReceivePack rp, ICollection<ReceiveCommand> commands) { using (var gitRepo = new GitSharp.Repository(repository.FullPath)) { var commit = gitRepo.Head.CurrentCommit; if (commit != null && commit.Message != null && commit.Message.ToLower().Contains("bugzid:")) { var bugzid = ParseBugzId(commit.Message); var hashBase = commit.Hash; foreach (var change in commit.Changes) { if (change == null) { continue; } var fileName = change.Name; var fileOldSha = string.Empty; if (change.ReferenceObject != null) { fileOldSha = change.ReferenceObject.Hash; } var fileNewSha = string.Empty; if (change.ChangedObject != null) { fileNewSha = change.ChangedObject.Hash; } var hashBaseParent = string.Empty; if (change.ReferenceCommit != null) { hashBaseParent = change.ReferenceCommit.Hash; } SubmitData(fileOldSha, hashBaseParent, fileNewSha, hashBase, bugzid, fileName, repository.Name); } } } }
private void Run(ReceivePack rp, string hook) { var processStartInfo = new ProcessStartInfo { FileName = hook, UseShellExecute = false, WindowStyle = ProcessWindowStyle.Hidden, CreateNoWindow = true, RedirectStandardOutput = true, RedirectStandardError = true, WorkingDirectory = FullPath }; var appSettings = AppSettings.FromAppConfig(); using (var process = Process.Start(processStartInfo)) { if(!appSettings.RunHooksSilently) { process.OutputDataReceived += (d, r) => rp.sendMessage(r.Data); process.ErrorDataReceived += (d, r) => rp.sendError(r.Data); } process.BeginOutputReadLine(); process.BeginErrorReadLine(); process.WaitForExit((int)appSettings.HookTimeout.TotalMilliseconds); process.Close(); } }
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); }
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(); } }
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(); } }
public void onPreReceive(ReceivePack rp, ICollection<ReceiveCommand> commands) { }
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); } }
public void onPreReceive(ReceivePack rp, ICollection <ReceiveCommand> commands) { }
public void OnPostReceive(ReceivePack rp, ICollection <ReceiveCommand> commands) { }
public void OnPostReceive(ReceivePack rp, ICollection<ReceiveCommand> commands) { }
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); }
public void OnPostReceive(ReceivePack rp, List <ReceiveCommand> commands) { }
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(); }
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(); }
public void OnPostReceive(ReceivePack rp, List<ReceiveCommand> commands) { }
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))); } } }
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); }
public void onPreReceive(ReceivePack rp, List <ReceiveCommand> commands) { }