| ... | ... |
@@ -124,7 +124,6 @@ sub startup {
|
| 124 | 124 |
|
| 125 | 125 |
# Repository home |
| 126 | 126 |
my $rep_home = $ENV{GITPREP_REP_HOME} || $self->home->rel_file('data/rep');
|
| 127 |
- $git->rep_home($rep_home); |
|
| 128 | 127 |
unless (-d $rep_home) {
|
| 129 | 128 |
mkdir $rep_home |
| 130 | 129 |
or croak "Can't create directory $rep_home: $!"; |
| ... | ... |
@@ -15,7 +15,6 @@ use Gitprep::Util; |
| 15 | 15 |
# Attributes |
| 16 | 16 |
has 'bin'; |
| 17 | 17 |
has default_encoding => 'UTF-8'; |
| 18 |
-has 'rep_home'; |
|
| 19 | 18 |
has text_exts => sub { ['txt'] };
|
| 20 | 19 |
has 'time_zone_second'; |
| 21 | 20 |
has 'app'; |
| ... | ... |
@@ -126,8 +125,7 @@ sub cmd_clone {
|
| 126 | 125 |
my ($self, $user, $project) = @_; |
| 127 | 126 |
|
| 128 | 127 |
# Repository |
| 129 |
- my $home = $self->rep_home; |
|
| 130 |
- my $rep = "$home/$user/$project.git"; |
|
| 128 |
+ my $rep = $self->app->rep_path($user, $project); |
|
| 131 | 129 |
|
| 132 | 130 |
# Working directory |
| 133 | 131 |
my $working_dir = $self->app->home->rel_file("/data/work/$user/$project");
|
| ... | ... |
@@ -138,8 +136,7 @@ sub cmd {
|
| 138 | 136 |
my ($self, $user, $project, @cmd) = @_; |
| 139 | 137 |
|
| 140 | 138 |
# Git command |
| 141 |
- my $home = $self->rep_home; |
|
| 142 |
- my $rep = "$home/$user/$project.git"; |
|
| 139 |
+ my $rep = $self->app->rep_path($user, $project); |
|
| 143 | 140 |
|
| 144 | 141 |
return $self->cmd_dir($rep, @cmd); |
| 145 | 142 |
} |
| ... | ... |
@@ -568,7 +565,6 @@ sub exists_branch {
|
| 568 | 565 |
my ($self, $user, $project) = @_; |
| 569 | 566 |
|
| 570 | 567 |
# Exists branch |
| 571 |
- my $home = $self->rep_home; |
|
| 572 | 568 |
my @cmd = $self->cmd($user, $project, 'branch'); |
| 573 | 569 |
open my $fh, "-|", @cmd |
| 574 | 570 |
or croak 'git branch failed'; |
| ... | ... |
@@ -991,14 +987,6 @@ sub references {
|
| 991 | 987 |
return \%refs; |
| 992 | 988 |
} |
| 993 | 989 |
|
| 994 |
-sub rep {
|
|
| 995 |
- my ($self, $user, $project) = @_; |
|
| 996 |
- |
|
| 997 |
- my $home = $self->rep_home; |
|
| 998 |
- |
|
| 999 |
- return "$home/$user/$project.git"; |
|
| 1000 |
-} |
|
| 1001 |
- |
|
| 1002 | 990 |
sub short_id {
|
| 1003 | 991 |
my ($self, $project) = (shift, shift); |
| 1004 | 992 |
|
| ... | ... |
@@ -657,7 +657,7 @@ sub _create_rep {
|
| 657 | 657 |
|
| 658 | 658 |
# Create repository directory |
| 659 | 659 |
my $git = $self->app->git; |
| 660 |
- my $rep = $git->rep($user, $project); |
|
| 660 |
+ my $rep = $self->app->rep_path($user, $project); |
|
| 661 | 661 |
mkdir $rep |
| 662 | 662 |
or croak "Can't create directory $rep: $!"; |
| 663 | 663 |
|
| ... | ... |
@@ -794,7 +794,7 @@ sub _create_user_dir {
|
| 794 | 794 |
my ($self, $user) = @_; |
| 795 | 795 |
|
| 796 | 796 |
# Create user directory |
| 797 |
- my $rep_home = $self->app->git->rep_home; |
|
| 797 |
+ my $rep_home = $self->app->rep_home; |
|
| 798 | 798 |
my $user_dir = "$rep_home/$user"; |
| 799 | 799 |
mkpath $user_dir; |
| 800 | 800 |
} |
| ... | ... |
@@ -812,7 +812,7 @@ sub _delete_user_dir {
|
| 812 | 812 |
my ($self, $user) = @_; |
| 813 | 813 |
|
| 814 | 814 |
# Delete user directory |
| 815 |
- my $rep_home = $self->app->git->rep_home; |
|
| 815 |
+ my $rep_home = $self->app->rep_home; |
|
| 816 | 816 |
my $user_dir = "$rep_home/$user"; |
| 817 | 817 |
rmtree $user_dir; |
| 818 | 818 |
} |
| ... | ... |
@@ -829,7 +829,7 @@ sub _delete_rep {
|
| 829 | 829 |
my ($self, $user, $project) = @_; |
| 830 | 830 |
|
| 831 | 831 |
# Delete repository |
| 832 |
- my $rep_home = $self->app->git->rep_home; |
|
| 832 |
+ my $rep_home = $self->app->rep_home; |
|
| 833 | 833 |
croak "Can't remove repository. repository home is empty" |
| 834 | 834 |
if !defined $rep_home || $rep_home eq ''; |
| 835 | 835 |
my $rep = "$rep_home/$user/$project.git"; |
| ... | ... |
@@ -861,7 +861,7 @@ sub _exists_rep {
|
| 861 | 861 |
my ($self, $user, $project) = @_; |
| 862 | 862 |
|
| 863 | 863 |
# Exists repository |
| 864 |
- my $rep = $self->app->git->rep($user, $project); |
|
| 864 |
+ my $rep = $self->app->rep_path($user, $project); |
|
| 865 | 865 |
|
| 866 | 866 |
return -e $rep; |
| 867 | 867 |
} |
| ... | ... |
@@ -871,8 +871,8 @@ sub _fork_rep {
|
| 871 | 871 |
|
| 872 | 872 |
# Fork repository |
| 873 | 873 |
my $git = $self->app->git; |
| 874 |
- my $rep = $git->rep($user, $project); |
|
| 875 |
- my $to_rep = $git->rep($to_user, $to_project); |
|
| 874 |
+ my $rep = $self->app->rep_path($user, $project); |
|
| 875 |
+ my $to_rep = $self->app->rep_path($to_user, $to_project); |
|
| 876 | 876 |
my @cmd = ( |
| 877 | 877 |
$git->bin, |
| 878 | 878 |
'clone', |
| ... | ... |
@@ -912,8 +912,8 @@ sub _rename_rep {
|
| 912 | 912 |
unless defined $user && defined $project && defined $renamed_project; |
| 913 | 913 |
|
| 914 | 914 |
# Rename repository |
| 915 |
- my $rep = $self->app->git->rep($user, $project); |
|
| 916 |
- my $renamed_rep = $self->app->git->rep($user, $renamed_project); |
|
| 915 |
+ my $rep = $self->app->rep_path($user, $project); |
|
| 916 |
+ my $renamed_rep = $self->app->rep_path($user, $renamed_project); |
|
| 917 | 917 |
move($rep, $renamed_rep) |
| 918 | 918 |
or croak "Can't move $rep to $renamed_rep: $!"; |
| 919 | 919 |
} |
| ... | ... |
@@ -18,7 +18,7 @@ my $session_user = shift; |
| 18 | 18 |
die "User not specifed" unless defined $session_user; |
| 19 | 19 |
|
| 20 | 20 |
# Application |
| 21 |
-my $app = Gitprep->new; |
|
| 21 |
+my $app = Mojo::Server->new->load_app("$FindBin::Bin/gitprep");
|
|
| 22 | 22 |
|
| 23 | 23 |
# Git |
| 24 | 24 |
my $git = $app->git; |
| ... | ... |
@@ -66,8 +66,8 @@ 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_home = $git->rep_home; |
|
| 70 |
-my $repository = "'$rep_home/$user/$project.git'"; |
|
| 69 |
+my $rep = $app->rep_path($user, $project); |
|
| 70 |
+my $repository = "'$rep'"; |
|
| 71 | 71 |
my @git_shell_cmd = ("git", "shell", "-c", "$verb $repository");
|
| 72 | 72 |
warn "@git_shell_cmd" if $debug; |
| 73 | 73 |
unless ($debug) {
|
| ... | ... |
@@ -90,7 +90,7 @@ 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 = $git->rep($user, $project); |
|
| 93 |
+ my $remote_rep = $app->rep_path($user, $project); |
|
| 94 | 94 |
|
| 95 | 95 |
# push branches |
| 96 | 96 |
{
|
| ... | ... |
@@ -14,7 +14,7 @@ |
| 14 | 14 |
my $service_cmd = $service; |
| 15 | 15 |
substr($service_cmd, 0, 4, ''); |
| 16 | 16 |
|
| 17 |
- my $rep = $git->rep($user, $project); |
|
| 17 |
+ my $rep = app->rep_path($user, $project); |
|
| 18 | 18 |
my @cmd = $git->cmd($user, $project, $service_cmd, '--stateless-rpc', '--advertise-refs', $rep); |
| 19 | 19 |
|
| 20 | 20 |
my ($cout, $cerr) = (Symbol::gensym, Symbol::gensym); |
| ... | ... |
@@ -65,8 +65,8 @@ |
| 65 | 65 |
or die "Can't close pipe for @cmd:$!"; |
| 66 | 66 |
|
| 67 | 67 |
my $content_type = 'text/plain; charset=UTF-8'; |
| 68 |
- my $rep_home = app->git->rep_home; |
|
| 69 |
- my $file = "$rep_home/$user/$project.git/info/refs"; |
|
| 68 |
+ my $rep = app->rep_path($user, $project); |
|
| 69 |
+ my $file = "$rep/info/refs"; |
|
| 70 | 70 |
if (-f $file) {
|
| 71 | 71 |
my $asset = Mojo::Asset::File->new(path => $file); |
| 72 | 72 |
my $content = $asset->slurp; |
| ... | ... |
@@ -9,7 +9,7 @@ |
| 9 | 9 |
|
| 10 | 10 |
my $git = app->git; |
| 11 | 11 |
|
| 12 |
- my $rep_dir = $git->rep($user, $project); |
|
| 12 |
+ my $rep_dir = app->rep_path($user, $project); |
|
| 13 | 13 |
my @cmd = $git->cmd($user, $project, $service, '--stateless-rpc', $rep_dir); |
| 14 | 14 |
|
| 15 | 15 |
# Command |
| ... | ... |
@@ -31,8 +31,8 @@ |
| 31 | 31 |
$content_type = 'application/x-git-packed-objects-toc'; |
| 32 | 32 |
} |
| 33 | 33 |
|
| 34 |
- my $rep_home = app->git->rep_home; |
|
| 35 |
- my $file = "$rep_home/$user/$project.git/$path"; |
|
| 34 |
+ my $rep = app->rep_path($user, $project); |
|
| 35 |
+ my $file = "$rep/$path"; |
|
| 36 | 36 |
if (-f $file) {
|
| 37 | 37 |
my $asset = Mojo::Asset::File->new(path => $file); |
| 38 | 38 |
my $content = $asset->slurp; |
| ... | ... |
@@ -63,7 +63,7 @@ |
| 63 | 63 |
my $url = url_for->to_abs; |
| 64 | 64 |
$url->base(undef); |
| 65 | 65 |
my $ssh_port = config->{basic}{ssh_port};
|
| 66 |
- my $rep_home = app->git->rep_home; |
|
| 66 |
+ my $rep_home = app->rep_home; |
|
| 67 | 67 |
my $execute_user = getpwuid($>); |
| 68 | 68 |
my $ssh_rep_url_base = defined app->config->{basic}{'ssh_rep_url_base'}
|
| 69 | 69 |
? app->config->{basic}{'ssh_rep_url_base'} : $rep_home;
|