Showing 5 changed files with 15 additions and 48 deletions
+1 -1
lib/Gitprep.pm
... ...
@@ -133,7 +133,7 @@ sub startup {
133 133
   # Model
134 134
   my $models = [
135 135
     {table => 'user', primary_key => 'id'},
136
-    {table => 'ssh_public_key', primary_key => ['user_id', 'key']},
136
+    {table => 'ssh_public_key', primary_key => 'key'},
137 137
     {table => 'project', primary_key => ['user_id', 'name']},
138 138
     {table => 'number', primary_key => 'key'},
139 139
     {table => 'collaboration', primary_key => ['user_id', 'project_name', 'collaborator_id']}
+4 -5
lib/Gitprep/Manager.pm
... ...
@@ -333,9 +333,7 @@ EOS
333 333
     my $sql = <<"EOS";
334 334
 create table ssh_public_key (
335 335
   row_id integer primary key autoincrement,
336
-  user_id not null default '',
337
-  key not null default '',
338
-  unique(user_id, key)
336
+  key not null unique default ''
339 337
 );
340 338
 EOS
341 339
     $dbi->execute($sql);
... ...
@@ -343,7 +341,8 @@ EOS
343 341
 
344 342
   # Create ssh_public_key columns
345 343
   my $ssh_public_key_columns = [
346
-    "title not null default ''",
344
+    "user_id not null default ''",
345
+    "title not null default ''"
347 346
   ];
348 347
   for my $column (@$ssh_public_key_columns) {
349 348
     eval { $dbi->execute("alter table ssh_public_key add column $column") };
... ...
@@ -555,7 +554,7 @@ sub _parse_authorized_keys_file {
555 554
       }
556 555
     }
557 556
     elsif ($line =~ /^$end_symbol/) {
558
-      if ($end_symbol > 0) {
557
+      if ($end_symbol_count > 0) {
559 558
         croak qq/$error_prefix "$end_symbol" is found more than one/;
560 559
       }
561 560
       else {
+4 -3
script/gitprep-shell
... ...
@@ -34,11 +34,11 @@ die "who the *heck* are you?" unless defined $ssh_connection;
34 34
 
35 35
 # SSH original command
36 36
 my $ssh_original_command = $ENV{SSH_ORIGINAL_COMMAND} || '';
37
-warn "ssh_original_command: $ssh_original_command";
37
+warn "ssh_original_command: $ssh_original_command" if $debug;
38 38
 
39 39
 # IP address
40 40
 my $ip = $ssh_connection || '(no-IP)';
41
-warn "ip: $ip";
41
+warn "ip: $ip" if $debug;
42 42
 $ip =~ s/ .*//;
43 43
 
44 44
 # Check new line of SSH original command
... ...
@@ -67,8 +67,9 @@ sub parse_ssh_original_command {
67 67
   $ssh_original_command ||= '';
68 68
 
69 69
   my $git_commands = "git-upload-pack|git-receive-pack|git-upload-archive";
70
-  if ($ssh_original_command =~ m(^($git_commands) '/([a-zA-Z_]+)/?(.*?)(?:\.git)?'$)) {
70
+  if ($ssh_original_command =~ m(^($git_commands) '.*/([a-zA-Z_]+)/([^\/]+?)\.git'$)) {
71 71
     my ($verb, $user, $project) = ($1, $2, $3);
72
+    warn "User:$user, Project:$project" if $debug;
72 73
     die "invalid repo name: '$project'" if $project !~ $project_re;
73 74
     return ($verb, $user, $project);
74 75
   }
+5 -38
templates/project.html.ep
... ...
@@ -51,10 +51,8 @@
51 51
   my $ssh_port = config->{basic}{ssh_port};
52 52
   my $rep_home = app->git->rep_home;
53 53
   my $execute_user = getpwuid($>);
54
-  my $ssh_rep_url_deprected = "ssh://$execute_user\@" . $url->host
55
-    . ($ssh_port ? ":$ssh_port" : '') . "$rep_home/$user/$project.git";
56 54
   my $ssh_rep_url = "ssh://$execute_user\@" . $url->host
57
-    . ($ssh_port ? ":$ssh_port" : '') . "/$user/$project.git";
55
+    . ($ssh_port ? ":$ssh_port" : '') . "$rep_home/$user/$project.git";
58 56
 
59 57
 %>
60 58
 
... ...
@@ -69,9 +67,8 @@
69 67
       % my $ssh_port = config->{basic}{ssh_port} || '';
70 68
       
71 69
       var logined = <%= $logined ? 'true' : 'false' %>;
72
-      var ssh_rep_url_deprecated = '';
70
+      var ssh_rep_url = '';
73 71
       if (logined) {
74
-        ssh_rep_url_deprecated = '<%= $ssh_rep_url_deprected %>';
75 72
         ssh_rep_url = '<%= $ssh_rep_url %>';
76 73
       }
77 74
       
... ...
@@ -81,17 +78,11 @@
81 78
         $('#access').text('Read-write');
82 79
       });
83 80
 
84
-      // Click SSH button
81
+      // Click SSH(old) button
85 82
       $('#btn_ssh').on('click', function () {
86 83
         $('#rep_url').val(ssh_rep_url);
87 84
         $('#access').text('Read-write');
88 85
       });
89
-            
90
-      // Click SSH(old) button
91
-      $('#btn_ssh_deprecated').on('click', function () {
92
-        $('#rep_url').val(ssh_rep_url_deprecated);
93
-        $('#access').text('Read-write');
94
-      });
95 86
 
96 87
       // Initialize
97 88
       $('#btn_http').trigger('click');
... ...
@@ -129,7 +120,6 @@
129 120
             <button class="btn" id="btn_http" style="margin-left:5px;padding:3px 6px;border-top-right-radius:0px; border-bottom-right-radius:0px"><%= $self->req->is_secure ? 'HTTPS' : 'HTTP' %></button>
130 121
             % if ($logined) {
131 122
               <button class="btn" id="btn_ssh" style="padding:3px 7px;border-radius:0">SSH</button>
132
-              <button class="btn" id="btn_ssh_deprecated" style="padding:3px 7px;border-radius:0">SSH(old)</button>
133 123
             % }
134 124
           </div>
135 125
           <input id="rep_url" type="text" style="width:635px;border-radius:0;padding:3px 7px;border-top-right-radius:3px;border-bottom-right-radius:3px">
... ...
@@ -169,7 +159,7 @@ touch README
169 159
 git init
170 160
 git add README
171 161
 git commit -m "first commit"
172
-git remote add origin <%= $ssh_rep_url_deprected %>
162
+git remote add origin <%= $ssh_rep_url %>
173 163
 git push -u origin master</pre>
174 164
       
175 165
       <div class="text-center" style="margin-bottom:10px">
... ...
@@ -177,34 +167,11 @@ git push -u origin master</pre>
177 167
       </div>
178 168
       
179 169
       <pre style="margin-bottom:30px">
180
-git remote add origin <%= $ssh_rep_url_deprected %>
170
+git remote add origin <%= $ssh_rep_url %>
181 171
 git push -u origin master</pre>
182 172
 
183 173
       <hr>
184 174
 
185
-      <h4>SSH(deprecated)</h4>
186
-      
187
-      <div class="text-center" style="margin-bottom:10px">
188
-        <b>Create a new repository on the command line via ssh</b>
189
-      </div>
190
-      
191
-      <pre style="margin-bottom:30px">
192
-touch README
193
-git init
194
-git add README
195
-git commit -m "first commit"
196
-git remote add origin <%= $ssh_rep_url_deprected %>
197
-git push -u origin master</pre>
198
-      
199
-      <div class="text-center" style="margin-bottom:10px">
200
-        <b>Push an existing repository from the command line via ssh</b>
201
-      </div>
202
-      
203
-      <pre style="margin-bottom:30px">
204
-git remote add origin <%= $ssh_rep_url_deprected %>
205
-git push -u origin master</pre>
206
-
207
-      <hr>
208 175
       % my $http_rep_url = url_for("$user/$project.git")->to_abs;
209 176
       <h4><%= uc url_for->to_abs->scheme %></h4>
210 177
 
+1 -1
templates/user-settings/ssh.html.ep
... ...
@@ -43,7 +43,7 @@
43 43
               if ($vc->constraints->{ascii}->($original_key_edit)) {
44 44
                 my $key = "$type $original_key_edit";
45 45
                 
46
-                my $row = app->dbi->model('ssh_public_key')->select(id => [$user, $key])->one;
46
+                my $row = app->dbi->model('ssh_public_key')->select(id => $key)->one;
47 47
                 
48 48
                 if ($row) {
49 49
                   return {result => 0, message => 'Key already exists'};