gitlabhq/doc/code/classes/PostReceive.html
2012-12-30 14:43:00 +02:00

149 lines
6.5 KiB
HTML

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>PostReceive</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../css/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../css/github.css" type="text/css" media="screen" />
<script src="../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/main.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<div class="banner">
<h1>
<span class="type">Class</span>
PostReceive
<span class="parent">&lt;
Object
</span>
</h1>
<ul class="files">
<li><a href="../files/app/workers/post_receive_rb.html">app/workers/post_receive.rb</a></li>
</ul>
</div>
<div id="bodyContent">
<div id="content">
<!-- Method ref -->
<div class="sectiontitle">Methods</div>
<dl class="methods">
<dt>P</dt>
<dd>
<ul>
<li>
<a href="#method-c-perform">perform</a>
</li>
</ul>
</dd>
</dl>
<!-- Methods -->
<div class="sectiontitle">Class Public methods</div>
<div class="method">
<div class="title method-title" id="method-c-perform">
<b>perform</b>(repo_path, oldrev, newrev, ref, identifier)
<a href="../classes/PostReceive.html#method-c-perform" name="method-c-perform" class="permalink">Link</a>
</div>
<div class="description">
</div>
<div class="sourcecode">
<p class="source-link">
Source:
<a href="javascript:toggleSource('method-c-perform_source')" id="l_method-c-perform_source">show</a>
</p>
<div id="method-c-perform_source" class="dyn-source">
<pre><span class="ruby-comment"># File app/workers/post_receive.rb, line 4</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">self</span>.<span class="ruby-identifier">perform</span>(<span class="ruby-identifier">repo_path</span>, <span class="ruby-identifier">oldrev</span>, <span class="ruby-identifier">newrev</span>, <span class="ruby-identifier">ref</span>, <span class="ruby-identifier">identifier</span>)
<span class="ruby-identifier">repo_path</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-constant">Gitlab</span>.<span class="ruby-identifier">config</span>.<span class="ruby-identifier">gitolite</span>.<span class="ruby-identifier">repos_path</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-string">&quot;&quot;</span>)
<span class="ruby-identifier">repo_path</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp">%r.git$/</span>, <span class="ruby-string">&quot;&quot;</span>)
<span class="ruby-identifier">repo_path</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp">%r^\//</span>, <span class="ruby-string">&quot;&quot;</span>)
<span class="ruby-identifier">project</span> = <span class="ruby-constant">Project</span>.<span class="ruby-identifier">find_with_namespace</span>(<span class="ruby-identifier">repo_path</span>)
<span class="ruby-keyword">return</span> <span class="ruby-keyword">false</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">project</span>.<span class="ruby-identifier">nil?</span>
<span class="ruby-comment"># Ignore push from non-gitlab users</span>
<span class="ruby-identifier">user</span> = <span class="ruby-keyword">if</span> <span class="ruby-identifier">identifier</span>.<span class="ruby-identifier">eql?</span> <span class="ruby-constant">Gitlab</span>.<span class="ruby-identifier">config</span>.<span class="ruby-identifier">gitolite</span>.<span class="ruby-identifier">admin_key</span>
<span class="ruby-identifier">email</span> = <span class="ruby-identifier">project</span>.<span class="ruby-identifier">commit</span>(<span class="ruby-identifier">newrev</span>).<span class="ruby-identifier">author</span>.<span class="ruby-identifier">email</span> <span class="ruby-keyword">rescue</span> <span class="ruby-keyword">nil</span>
<span class="ruby-constant">User</span>.<span class="ruby-identifier">find_by_email</span>(<span class="ruby-identifier">email</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">email</span>
<span class="ruby-keyword">elsif</span> <span class="ruby-regexp">%r^[A-Z0-9._%a-z\-]+@(?:[A-Z0-9a-z\-]+\.)+[A-Za-z]{2,4}$/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-identifier">identifier</span>)
<span class="ruby-constant">User</span>.<span class="ruby-identifier">find_by_email</span>(<span class="ruby-identifier">identifier</span>)
<span class="ruby-keyword">else</span>
<span class="ruby-constant">Key</span>.<span class="ruby-identifier">find_by_identifier</span>(<span class="ruby-identifier">identifier</span>).<span class="ruby-identifier">try</span>(<span class="ruby-value">:user</span>)
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">return</span> <span class="ruby-keyword">false</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">user</span>
<span class="ruby-identifier">project</span>.<span class="ruby-identifier">trigger_post_receive</span>(<span class="ruby-identifier">oldrev</span>, <span class="ruby-identifier">newrev</span>, <span class="ruby-identifier">ref</span>, <span class="ruby-identifier">user</span>)
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
</div>
</div>
</body>
</html>