Merge remote-tracking branch 'official/master' into saltation
[gitorious:taladars-gitorious-saltation.git] / app / views / repositories / _clone_urls.html.erb
1 <%
2 #--
3 #   Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
4 #
5 #   This program is free software: you can redistribute it and/or modify
6 #   it under the terms of the GNU Affero General Public License as published by
7 #   the Free Software Foundation, either version 3 of the License, or
8 #   (at your option) any later version.
9 #
10 #   This program is distributed in the hope that it will be useful,
11 #   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 #   GNU Affero General Public License for more details.
14 #
15 #   You should have received a copy of the GNU Affero General Public License
16 #   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 #++
18 %>
19
20 <ul>
21           <li>
22     <% content_for :extra_head do %>
23       <link rel="vcs-git" href="<%= h(repository.clone_url) -%>" title="<%= t("views.repos.show_page_title", :repo => repository.name, :title => h(@owner.title)) -%>" />
24     <% end %>
25                 <div class="clone_urls">
26                         <form class="clone_urls_form">
27                                         <p><strong>Clone &amp; push urls</strong></p>
28                                         <% unless repository.private? %>
29                                           <p class="clone_radio">
30                                             <label for="git-<%= repository.id %>"><input type="radio" id="git-<%= repository.id %>" name="url-<%= repository.id %>" value="<%= h(repository.clone_url) -%>" <%= git_or_ssh_url_checked(repository, :git) -%>>GIT</label>
31                                           </p>
32                                           <% if repository.http_cloning? %>
33               <% content_for :extra_head do %>
34                 <link rel="vcs-git" href="<%= h(repository.http_clone_url) -%>" title="<%= t("views.repos.show_page_title", :repo => repository.name, :title => h(@owner.title)) -%>" />
35               <% end %>
36                                                   <p class="clone_radio">
37                                                     <label for="http-<%= repository.id %>"><input type="radio" id="http-<%= repository.id %>" name="url-<%= repository.id %>" value="<%= h(repository.http_clone_url) -%>">HTTP</label>
38                                                   </p>
39                                           <% end %>
40                                         <% end %>
41                                         <% if logged_in? && repository.writable_by?(current_user) -%>
42                                         <p class="clone_radio">
43                                           <label for="push-<%= repository.id %>"><input id="push-<%= repository.id %>" type="radio" name="url-<%= repository.id %>" value="<%= h(repository.push_url) -%>" <%= git_or_ssh_url_checked(repository, :ssh) -%>>SSH</label>
44                                         </p>
45                                         <% end -%>
46                                         <p class="clone-copy <%= css_class_for_clone_url_field(repository) -%>">
47                                           <input type="text" readonly="readonly" id="clone-url-<%= repository.id %>" value="" />
48                                           <a href="#help" id="clone-help-<%= repository.id -%>" class="clone-help-toggler">?</a>
49                                         </p>
50                         </form>
51                         <div id="clone-help-<%= repository.id -%>-box" class="clone-help-text" style="display:none;">
52         <% if logged_in? && current_user.site_admin? -%>
53           <% content_for :extra_head do %>
54             <link rel="vcs-git" href="<%= h(repository.push_url) -%>" title="<%= t("views.repos.show_page_title", :repo => repository.name, :title => h(@owner.title)) -%>" />
55           <% end %>
56           <p>Repository path: <code><%= h(repository.full_repository_path) -%></a></code></p>
57         <% end -%>
58         <% if logged_in? && current_user.can_write_to?(repository) -%>
59         <p>
60           Adding this repository as a pushable origin:
61 <pre>
62 # Add the push url to your already existing origin:
63 git remote set-url --push origin <%= repository.push_url %>
64 # to push the master branch to the origin remote we added above:
65 git push origin master
66 # after that you can just do:
67 git push
68 </pre></p>
69         <% end -%>
70         <p>Cloning this repository:
71 <pre>
72 git clone <%= repository.clone_url -%> <%=h repository.name %>
73 cd <%=h repository.name -%>
74 </pre></p>
75         <p>Add this repository as a remote to an existing local repository:
76 <pre>
77 git remote add <%=h repository.name -%> <%= repository.clone_url %>
78 git fetch <%=h repository.name %>
79 git checkout -b my-local-tracking-branch <%=h repository.name -%>/master_or_other_branch
80 </pre></p>
81                 </div>  
82           </li>
83 </ul>
84
85 <script type="text/javascript" charset="utf-8">
86         $(document).ready(function() {
87                 var standard = $("#git-<%= repository.id -%>:checked, #http-<%= repository.id -%>:checked, #push-<%= repository.id -%>:checked").val();
88                 $('#clone-url-<%= repository.id -%>').val(standard);
89                 
90                 $('#git-<%= repository.id %>').click(function () {
91                         var text = $('#git-<%= repository.id %>').val();
92                         $('#clone-url-<%= repository.id %>').val(text);
93                 });
94                 
95                 $('#http-<%= repository.id %>').click(function () {
96                         var text = $('#http-<%= repository.id %>').val();
97                         $('#clone-url-<%= repository.id %>').val(text);
98                 });
99                 $('#push-<%= repository.id %>').click(function () {
100                         var text = $('#push-<%= repository.id %>').val();
101                         $('#clone-url-<%= repository.id %>').val(text);
102                 });
103
104                 $('#clone-url-<%= repository.id %>').click(function () {
105                         this.select();
106                 });
107         });
108 </script>