From: Dan Brook Date: Tue, 11 Jan 2011 22:07:38 +0000 (-0500) Subject: Allow top-level directories in the Repo constructor. X-Git-Tag: 0.002007~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=dc8badf5e3050d832e552e8d7f37d6f9325ec457;p=catagits%2FGitalist.git Allow top-level directories in the Repo constructor. The problem being that the constructor couldn't handle paths like foo/repo which is what CollectionOfRepositories considers (rightly) a repo path. --- diff --git a/lib/Gitalist/Git/Repository.pm b/lib/Gitalist/Git/Repository.pm index 328e10a..571656e 100644 --- a/lib/Gitalist/Git/Repository.pm +++ b/lib/Gitalist/Git/Repository.pm @@ -25,7 +25,12 @@ class Gitalist::Git::Repository with Gitalist::Git::HasUtils { # Last path component becomes $self->name # Full path to git objects becomes $self->path my $name = $dir->dir_list(-1); - $dir = $dir->subdir('.git') if (-f $dir->file('.git', 'HEAD')); + if(-f $dir->file('.git', 'HEAD')) { # Non-bare repo above .git + $dir = $dir->subdir('.git'); + $name = $dir->dir_list(-2, 1); # .../name/.git + } elsif('.git' eq $dir->dir_list(-1)) { # Non-bare repo in .git + $name = $dir->dir_list(-2); + } confess("Can't find a git repository at " . $dir) unless ( -f $dir->file('HEAD') ); return $class->$orig(name => $name,