UNPKG

gitlab

Version:
293 lines (198 loc) 16.2 kB
<!DOCTYPE html> <html> <head> <title>ProjectRepository.coffee</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"> <link rel="stylesheet" media="all" href="docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <ul id="jump_to"> <li> <a class="large" href="javascript:void(0);">Jump To &hellip;</a> <a class="small" href="javascript:void(0);">+</a> <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="ApiBase.html"> ApiBase.coffee </a> <a class="source" href="ApiBaseHTTP.html"> ApiBaseHTTP.coffee </a> <a class="source" href="ApiV3.html"> ApiV3.coffee </a> <a class="source" href="BaseModel.html"> BaseModel.coffee </a> <a class="source" href="Groups.html"> Groups.coffee </a> <a class="source" href="Issues.html"> Issues.coffee </a> <a class="source" href="ProjectDeployKeys.html"> ProjectDeployKeys.coffee </a> <a class="source" href="ProjectHooks.html"> ProjectHooks.coffee </a> <a class="source" href="ProjectIssues.html"> ProjectIssues.coffee </a> <a class="source" href="ProjectMembers.html"> ProjectMembers.coffee </a> <a class="source" href="ProjectMergeRequests.html"> ProjectMergeRequests.coffee </a> <a class="source" href="ProjectMilestones.html"> ProjectMilestones.coffee </a> <a class="source" href="ProjectRepository.html"> ProjectRepository.coffee </a> <a class="source" href="Projects.html"> Projects.coffee </a> <a class="source" href="Users.html"> Users.coffee </a> <a class="source" href="Utils.html"> Utils.coffee </a> <a class="source" href="index.html"> index.coffee </a> </div> </li> </ul> <ul class="sections"> <li id="title"> <div class="annotation"> <h1>ProjectRepository.coffee</h1> </div> </li> <li id="section-1"> <div class="annotation"> <div class="pilwrap "> <a class="pilcrow" href="#section-1">&#182;</a> </div> </div> <div class="content"><div class='highlight'><pre>BaseModel = <span class="hljs-built_in">require</span> <span class="hljs-string">'../BaseModel'</span> Utils = <span class="hljs-built_in">require</span> <span class="hljs-string">'../Utils'</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ProjectRepository</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">BaseModel</span></span></pre></div></div> </li> <li id="section-2"> <div class="annotation"> <div class="pilwrap "> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>=== Branches</p> </div> <div class="content"><div class='highlight'><pre> <span class="hljs-attribute">listBranches</span>: <span class="hljs-function"><span class="hljs-params">(projectId, fn = <span class="hljs-literal">null</span>)</span> =&gt;</span> <span class="hljs-property">@debug</span> <span class="hljs-string">"Projects::listBranches()"</span> <span class="hljs-property">@get</span> <span class="hljs-string">"projects/<span class="hljs-subst">#{Utils.parseProjectId projectId}</span>/repository/branches"</span>, <span class="hljs-function"><span class="hljs-params">(data)</span> =&gt;</span> fn data <span class="hljs-keyword">if</span> fn <span class="hljs-attribute">showBranch</span>: <span class="hljs-function"><span class="hljs-params">(projectId, branchId, fn = <span class="hljs-literal">null</span>)</span> =&gt;</span> <span class="hljs-property">@debug</span> <span class="hljs-string">"Projects::branch()"</span> <span class="hljs-property">@get</span> <span class="hljs-string">"projects/<span class="hljs-subst">#{Utils.parseProjectId projectId}</span>/repository/branches/<span class="hljs-subst">#{encodeURI branchId}</span>"</span>, <span class="hljs-function"><span class="hljs-params">(data)</span> =&gt;</span> fn data <span class="hljs-keyword">if</span> fn <span class="hljs-attribute">protectBranch</span>: <span class="hljs-function"><span class="hljs-params">(projectId, branchId, fn = <span class="hljs-literal">null</span>)</span> =&gt;</span> <span class="hljs-property">@debug</span> <span class="hljs-string">"Projects::protectBranch()"</span> <span class="hljs-property">@put</span> <span class="hljs-string">"projects/<span class="hljs-subst">#{Utils.parseProjectId projectId}</span>/repository/branches/<span class="hljs-subst">#{encodeURI branchId}</span>/protect"</span>, <span class="hljs-literal">null</span>, <span class="hljs-function"><span class="hljs-params">(data)</span> =&gt;</span> fn data <span class="hljs-keyword">if</span> fn <span class="hljs-attribute">unprotectBranch</span>: <span class="hljs-function"><span class="hljs-params">(projectId, branchId, fn = <span class="hljs-literal">null</span>)</span> =&gt;</span> <span class="hljs-property">@debug</span> <span class="hljs-string">"Projects::unprotectBranch()"</span> <span class="hljs-property">@put</span> <span class="hljs-string">"projects/<span class="hljs-subst">#{Utils.parseProjectId projectId}</span>/repository/branches/<span class="hljs-subst">#{encodeURI branchId}</span>/unprotect"</span>, <span class="hljs-literal">null</span>, <span class="hljs-function"><span class="hljs-params">(data)</span> =&gt;</span> fn data <span class="hljs-keyword">if</span> fn <span class="hljs-attribute">createBranch</span>: <span class="hljs-function"><span class="hljs-params">(params = {}, fn = <span class="hljs-literal">null</span>)</span> =&gt;</span> <span class="hljs-property">@debug</span> <span class="hljs-string">"Projects::createBranch()"</span>, params <span class="hljs-property">@post</span> <span class="hljs-string">"projects/<span class="hljs-subst">#{Utils.parseProjectId params.projectId}</span>/repository/branches"</span>, params, <span class="hljs-function"><span class="hljs-params">(data)</span> =&gt;</span> fn data <span class="hljs-keyword">if</span> fn <span class="hljs-attribute">deleteBranch</span>: <span class="hljs-function"><span class="hljs-params">(projectId, branchId, fn = <span class="hljs-literal">null</span>)</span> =&gt;</span> <span class="hljs-property">@debug</span> <span class="hljs-string">"Projects::deleteBranch()"</span> <span class="hljs-property">@delete</span> <span class="hljs-string">"projects/<span class="hljs-subst">#{Utils.parseProjectId projectId}</span>/repository/branches/<span class="hljs-subst">#{encodeURI branchId}</span>"</span>, <span class="hljs-function"><span class="hljs-params">(data)</span> =&gt;</span> fn data <span class="hljs-keyword">if</span> fn</pre></div></div> </li> <li id="section-3"> <div class="annotation"> <div class="pilwrap "> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>=== Tags</p> </div> <div class="content"><div class='highlight'><pre> <span class="hljs-attribute">listTags</span>: <span class="hljs-function"><span class="hljs-params">(projectId, fn = <span class="hljs-literal">null</span>)</span> =&gt;</span> <span class="hljs-property">@debug</span> <span class="hljs-string">"Projects::listTags()"</span> <span class="hljs-property">@get</span> <span class="hljs-string">"projects/<span class="hljs-subst">#{Utils.parseProjectId projectId}</span>/repository/tags"</span>, <span class="hljs-function"><span class="hljs-params">(data)</span> =&gt;</span> fn data <span class="hljs-keyword">if</span> fn</pre></div></div> </li> <li id="section-4"> <div class="annotation"> <div class="pilwrap "> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>=== Commits</p> </div> <div class="content"><div class='highlight'><pre> <span class="hljs-attribute">listCommits</span>: <span class="hljs-function"><span class="hljs-params">(projectId, fn = <span class="hljs-literal">null</span>)</span> =&gt;</span> <span class="hljs-property">@debug</span> <span class="hljs-string">"Projects::listCommits()"</span> <span class="hljs-property">@get</span> <span class="hljs-string">"projects/<span class="hljs-subst">#{Utils.parseProjectId projectId}</span>/repository/commits"</span>, <span class="hljs-function"><span class="hljs-params">(data)</span> =&gt;</span> fn data <span class="hljs-keyword">if</span> fn <span class="hljs-attribute">showCommit</span>: <span class="hljs-function"><span class="hljs-params">(projectId, commitId, fn = <span class="hljs-literal">null</span>)</span> =&gt;</span> <span class="hljs-property">@debug</span> <span class="hljs-string">"Projects::commit()"</span> <span class="hljs-property">@get</span> <span class="hljs-string">"projects/<span class="hljs-subst">#{Utils.parseProjectId projectId}</span>/repository/branches/<span class="hljs-subst">#{parseInt commitId}</span>"</span>, <span class="hljs-function"><span class="hljs-params">(data)</span> =&gt;</span> fn data <span class="hljs-keyword">if</span> fn <span class="hljs-attribute">diffCommit</span>: <span class="hljs-function"><span class="hljs-params">(projectId, sha, fn = <span class="hljs-literal">null</span>)</span> =&gt;</span> <span class="hljs-property">@debug</span> <span class="hljs-string">"Projects::diffCommit()"</span> <span class="hljs-property">@get</span> <span class="hljs-string">"projects/<span class="hljs-subst">#{Utils.parseProjectId projectId}</span>/repository/branches/<span class="hljs-subst">#{sha}</span>"</span>, <span class="hljs-function"><span class="hljs-params">(data)</span> =&gt;</span> fn data <span class="hljs-keyword">if</span> fn</pre></div></div> </li> <li id="section-5"> <div class="annotation"> <div class="pilwrap "> <a class="pilcrow" href="#section-5">&#182;</a> </div> <p>=== Tree</p> </div> <div class="content"><div class='highlight'><pre> <span class="hljs-attribute">listTree</span>: <span class="hljs-function"><span class="hljs-params">(projectId, params = {}, fn = <span class="hljs-literal">null</span>)</span> =&gt;</span> <span class="hljs-property">@debug</span> <span class="hljs-string">"Projects::listTree()"</span> <span class="hljs-keyword">if</span> <span class="hljs-string">'function'</span> <span class="hljs-keyword">is</span> <span class="hljs-keyword">typeof</span>(params) fn = params params = {} <span class="hljs-property">@get</span> <span class="hljs-string">"projects/<span class="hljs-subst">#{Utils.parseProjectId projectId}</span>/repository/tree"</span>, params, <span class="hljs-function"><span class="hljs-params">(data)</span> =&gt;</span> fn data <span class="hljs-keyword">if</span> fn</pre></div></div> </li> <li id="section-6"> <div class="annotation"> <div class="pilwrap "> <a class="pilcrow" href="#section-6">&#182;</a> </div> <p>== Files</p> </div> <div class="content"><div class='highlight'><pre> <span class="hljs-attribute">showFile</span>: <span class="hljs-function"><span class="hljs-params">(projectId, params = {}, fn = <span class="hljs-literal">null</span>)</span> =&gt;</span> <span class="hljs-keyword">if</span> <span class="hljs-string">'function'</span> <span class="hljs-keyword">is</span> <span class="hljs-keyword">typeof</span> params fn = params params = projectId <span class="hljs-keyword">else</span> params.projectId = projectId <span class="hljs-property">@debug</span> <span class="hljs-string">"Projects::showFile()"</span>, params <span class="hljs-keyword">if</span> params.file_path <span class="hljs-keyword">and</span> params.ref <span class="hljs-property">@get</span> <span class="hljs-string">"projects/<span class="hljs-subst">#{Utils.parseProjectId params.projectId}</span>/repository/files"</span>, params, <span class="hljs-function"><span class="hljs-params">(data)</span> =&gt;</span> fn data <span class="hljs-keyword">if</span> fn <span class="hljs-attribute">createFile</span>: <span class="hljs-function"><span class="hljs-params">(params = {}, fn = <span class="hljs-literal">null</span>)</span> =&gt;</span> <span class="hljs-property">@debug</span> <span class="hljs-string">"Projects::createFile()"</span>, params <span class="hljs-property">@post</span> <span class="hljs-string">"projects/<span class="hljs-subst">#{Utils.parseProjectId params.projectId}</span>/repository/files"</span>, params, <span class="hljs-function"><span class="hljs-params">(data)</span> =&gt;</span> fn data <span class="hljs-keyword">if</span> fn <span class="hljs-attribute">updateFile</span>: <span class="hljs-function"><span class="hljs-params">(params = {}, fn = <span class="hljs-literal">null</span>)</span> =&gt;</span> <span class="hljs-property">@debug</span> <span class="hljs-string">"Projects::updateFile()"</span>, params <span class="hljs-property">@put</span> <span class="hljs-string">"projects/<span class="hljs-subst">#{Utils.parseProjectId params.projectId}</span>/repository/files"</span>, params, <span class="hljs-function"><span class="hljs-params">(data)</span> =&gt;</span> fn data <span class="hljs-keyword">if</span> fn</pre></div></div> </li> <li id="section-7"> <div class="annotation"> <div class="pilwrap "> <a class="pilcrow" href="#section-7">&#182;</a> </div> <h1 id="todo-">TODO:</h1> <ul> <li>Raw file content</li> <li>Raw blob content</li> <li>Get file archive</li> <li>Delete existing file in repository</li> </ul> </div> <div class="content"><div class='highlight'><pre> <span class="hljs-built_in">module</span>.exports = <span class="hljs-function"><span class="hljs-params">(client)</span> -&gt;</span> <span class="hljs-keyword">new</span> ProjectRepository client</pre></div></div> </li> </ul> </div> </body> </html>