summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Sørensen <johan@johansorensen.com>2008-02-04 00:03:41 +0100
committerJohan Sørensen <johan@johansorensen.com>2008-02-04 00:03:55 +0100
commitfc42b62ecabfb2449a8e6deaa4ff399e8ddc7a2b (patch)
treed907ab1f75438cb9b47c7cde425a3a503c5e8b6e
parent49a2c203531d114059cde68488f5ef17b07c8ed4 (diff)
downloadgitorious-mainline-outdated-fc42b62ecabfb2449a8e6deaa4ff399e8ddc7a2b.zip
gitorious-mainline-outdated-fc42b62ecabfb2449a8e6deaa4ff399e8ddc7a2b.tar.gz
gitorious-mainline-outdated-fc42b62ecabfb2449a8e6deaa4ff399e8ddc7a2b.tar.bz2
Added a failsafe for checking that the repos deletion path is sane
-rw-r--r--TODO.txt2
-rw-r--r--app/models/project.rb2
-rw-r--r--app/models/repository.rb2
-rw-r--r--lib/git_backend.rb6
4 files changed, 8 insertions, 4 deletions
diff --git a/TODO.txt b/TODO.txt
index 50a7b22..39b2a0c 100644
--- a/TODO.txt
+++ b/TODO.txt
@@ -23,7 +23,7 @@
[ ] Detect renames etc when showing a commit
[ ] Always add a "mainline-upstream" branch that track the mainline repos automagically to clones
[ ] email repository owners when there's a new comment
-[ ] Clean up in Diff::Display::Unified
+[*] Clean up in Diff::Display::Unified
---
a ProjectMirror that sucks in svn repositories. They need to be differentiated form normal projects (don't display owner etc, since it's a mirror). Also, the mainline repository should probably be immutable so people can commit changes to the actual mirror.
diff --git a/app/models/project.rb b/app/models/project.rb
index 564ed65..92a4ad2 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -2,7 +2,7 @@ class Project < ActiveRecord::Base
acts_as_taggable
belongs_to :user
- has_many :comments
+ has_many :comments, :dependent => :destroy
has_many :repositories, :order => "mainline desc, created_at asc",
:dependent => :destroy
has_one :mainline_repository, :conditions => ["mainline = ?", true],
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 4a4b15e..1a3d7a5 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -97,7 +97,7 @@ class Repository < ActiveRecord::Base
def create_delete_repos_task
Task.create!(:target_class => self.class.name,
- :command => "delete_git_repository", :arguments => [gitdir]) # fixme: gitdir is probably gone in after_destroy
+ :command => "delete_git_repository", :arguments => [gitdir])
end
protected
diff --git a/lib/git_backend.rb b/lib/git_backend.rb
index 889b38d..8fb9788 100644
--- a/lib/git_backend.rb
+++ b/lib/git_backend.rb
@@ -20,7 +20,11 @@ class GitBackend
end
def delete!(repos_path)
- FileUtils.rm_rf(repos_path)
+ if repos_path.index(GitoriousConfig["repository_base_path"]) == 0
+ FileUtils.rm_rf(repos_path)
+ else
+ raise "bad path"
+ end
end
def repository_has_commits?(repos_path)