Showing 4 changed files with 42 additions and 34 deletions
-8
lib/Gitprep.pm
... ...
@@ -72,14 +72,6 @@ sub work_rep_info {
72 72
   return $info;
73 73
 }
74 74
 
75
-sub rep_path {
76
-  my ($self, $user, $project) = @_;
77
-  
78
-  my $rep_path = $self->rep_home . "/$user/$project.git";
79
-  
80
-  return $rep_path
81
-}
82
-
83 75
 sub startup {
84 76
   my $self = shift;
85 77
   
+34 -21
lib/Gitprep/Manager.pm
... ...
@@ -678,41 +678,44 @@ sub _create_rep {
678 678
   
679 679
   # Create repository directory
680 680
   my $git = $self->app->git;
681
-  my $rep = $self->app->rep_path($user, $project);
682
-  mkdir $rep
683
-    or croak "Can't create directory $rep: $!";
681
+  
682
+  my $rep_info = $self->app->rep_info($user, $project);
683
+  my $rep_git_dir = $rep_info->{git_dir};
684
+  
685
+  mkdir $rep_git_dir
686
+    or croak "Can't create directory $rep_git_dir: $!";
684 687
   
685 688
   eval {
686 689
     # Git init
687 690
     {
688
-      my @git_init_cmd = $git->cmd_dir($rep, 'init', '--bare');
691
+      my @git_init_cmd = $git->cmd_dir($rep_git_dir, 'init', '--bare');
689 692
       Gitprep::Util::run_command(@git_init_cmd)
690 693
         or croak  "Can't execute git init --bare:@git_init_cmd";
691 694
     }
692 695
     
693 696
     # Add git-daemon-export-ok
694 697
     {
695
-      my $file = "$rep/git-daemon-export-ok";
698
+      my $file = "$rep_git_dir/git-daemon-export-ok";
696 699
       open my $fh, '>', $file
697 700
         or croak "Can't create git-daemon-export-ok: $!"
698 701
     }
699 702
     
700 703
     # HTTP support
701 704
     my @git_update_server_info_cmd = $git->cmd_dir(
702
-      $rep,
705
+      $rep_git_dir,
703 706
       '--bare',
704 707
       'update-server-info'
705 708
     );
706 709
     Gitprep::Util::run_command(@git_update_server_info_cmd)
707 710
       or croak "Can't execute git --bare update-server-info";
708
-    move("$rep/hooks/post-update.sample", "$rep/hooks/post-update")
711
+    move("$rep_git_dir/hooks/post-update.sample", "$rep_git_dir/hooks/post-update")
709 712
       or croak "Can't move post-update";
710 713
     
711 714
     # Description
712 715
     my $description = $opts->{description};
713 716
     $description = '' unless defined $description;
714 717
     {
715
-      my $file = "$rep/description";
718
+      my $file = "$rep_git_dir/description";
716 719
       open my $fh, '>', $file
717 720
         or croak "Can't open $file: $!";
718 721
       print $fh encode('UTF-8', $description)
... ...
@@ -790,7 +793,7 @@ sub _create_rep {
790 793
           $temp_work,
791 794
           'push',
792 795
           '-q',
793
-          $rep,
796
+          $rep_git_dir,
794 797
           'master'
795 798
         );
796 799
         # (This is bad, but --quiet option can't supress in old git)
... ...
@@ -800,7 +803,7 @@ sub _create_rep {
800 803
     }
801 804
   };
802 805
   if (my $e = $@) {
803
-    rmtree $rep;
806
+    rmtree $rep_git_dir;
804 807
     croak $e;
805 808
   }
806 809
 }
... ...
@@ -883,9 +886,10 @@ sub _exists_rep {
883 886
   my ($self, $user, $project) = @_;
884 887
   
885 888
   # Exists repository
886
-  my $rep = $self->app->rep_path($user, $project);
889
+  my $rep_info = $self->app->rep_info($user, $project);
890
+  my $rep_git_dir = $rep_info->{git_dir};
887 891
   
888
-  return -e $rep;
892
+  return -e $rep_git_dir;
889 893
 }
890 894
 
891 895
 sub _fork_rep {
... ...
@@ -893,21 +897,26 @@ sub _fork_rep {
893 897
   
894 898
   # Fork repository
895 899
   my $git = $self->app->git;
896
-  my $rep = $self->app->rep_path($user, $project);
897
-  my $to_rep = $self->app->rep_path($to_user, $to_project);
900
+  
901
+  my $rep_info = $self->app->rep_info($user, $project);
902
+  my $rep_git_dir = $rep_info->{git_dir};
903
+  
904
+  my $to_rep_info = $self->app->rep_info($to_user, $to_project);
905
+  my $to_rep_git_dir = $to_rep_info->{git_dir};
906
+
898 907
   my @cmd = (
899 908
     $git->bin,
900 909
     'clone',
901 910
     '-q',
902 911
     '--bare',
903
-    $rep,
904
-    $to_rep
912
+    $rep_git_dir,
913
+    $to_rep_git_dir
905 914
   );
906 915
   Gitprep::Util::run_command(@cmd)
907 916
     or croak "Can't fork repository(_fork_rep): @cmd";
908 917
   
909 918
   # Copy description
910
-  copy "$rep/description", "$to_rep/description"
919
+  copy "$rep_git_dir/description", "$to_rep_git_dir/description"
911 920
     or croak "Can't copy description file(_fork_rep)";
912 921
 }
913 922
 
... ...
@@ -934,10 +943,14 @@ sub _rename_rep {
934 943
     unless defined $user && defined $project && defined $renamed_project;
935 944
 
936 945
   # Rename repository
937
-  my $rep = $self->app->rep_path($user, $project);
938
-  my $renamed_rep = $self->app->rep_path($user, $renamed_project);
939
-  move($rep, $renamed_rep)
940
-    or croak "Can't move $rep to $renamed_rep: $!";
946
+  my $rep_info = $self->app->rep_info($user, $project);
947
+  my $rep_git_dir = $rep_info->{git_dir};
948
+  
949
+  my $renamed_rep_info = $self->app->rep_info($user, $renamed_project);
950
+  my $renamed_rep_git_dir = $renamed_rep_info->{git_dir};
951
+
952
+  move($rep_git_dir, $renamed_rep_git_dir)
953
+    or croak "Can't move $rep_git_dir to $renamed_rep_git_dir: $!";
941 954
 }
942 955
 
943 956
 1;
+3 -2
script/gitprep-shell
... ...
@@ -66,8 +66,9 @@ die qq|User "$session_user" can't access repository "$user/$project.git"\n|
66 66
   unless $can_access; 
67 67
 
68 68
 # Command
69
-my $rep = $app->rep_path($user, $project);
70
-my $repository = "'$rep'";
69
+my $rep_info = $app->rep_info($user, $project);
70
+my $rep_git_dir = $rep_info->{git_dir};
71
+my $repository = "'$rep_git_dir'";
71 72
 my @git_shell_cmd = ("git", "shell", "-c", "$verb $repository");
72 73
 warn "@git_shell_cmd" if $debug;
73 74
 unless ($debug) {
+5 -3
script/import_rep
... ...
@@ -90,18 +90,20 @@ for my $rep (glob "$rep_dir/*") {
90 90
     # Push repository
91 91
     chdir $rep
92 92
       or warn "Can't change directory $rep: $!\n";
93
-    my $remote_rep = $app->rep_path($user, $project);
93
+    
94
+    my $remote_rep_info = $app->rep_info($user, $project);
95
+    my $remote_rep_git_dir = $remote_rep_info->{git_dir};
94 96
     
95 97
     # push branches
96 98
     {
97
-      my @cmd = ('git', 'push', $remote_rep, '--all');
99
+      my @cmd = ('git', 'push', $remote_rep_git_dir, '--all');
98 100
       system(@cmd) == 0
99 101
         or warn "Can't push branches: @cmd";
100 102
     }
101 103
     
102 104
     # push tags
103 105
     {
104
-      my @cmd = ('git', 'push', $remote_rep, '--tags');
106
+      my @cmd = ('git', 'push', $remote_rep_git_dir, '--tags');
105 107
       system(@cmd) == 0
106 108
         or warn "Can't push tags: @cmd";
107 109
     }