lib/gitauth/repo.rb in brownbeagle-gitauth-0.0.3 vs lib/gitauth/repo.rb in brownbeagle-gitauth-0.0.3.3
- old
+ new
@@ -30,11 +30,11 @@
return false if name.nil? || path.nil?
return false if self.get(name) || self.all.any? { |r| r.path == path } || name !~ NAME_RE || path !~ NAME_RE
repository = self.new(name, path)
return false unless repository.create_repo!
self.add_item(repository)
- return true
+ return repository
end
attr_accessor :name, :path, :permissions
def initialize(name, path, auto_create = false)
@@ -87,19 +87,30 @@
path = self.real_path
unless File.exist?(path) && File.directory?(path)
FileUtils.mkdir_p(path)
output = ""
Dir.chdir(path) do
- IO.popen("git init --bare") { |f| output << f.read }
+ IO.popen("git --bare init") { |f| output << f.read }
end
return !!(output =~ /Initialized empty Git repository/)
end
end
def destroy!
FileUtils.rm_rf(self.real_path) if File.exist?(self.real_path)
self.class.all.reject! { |r| r == self }
self.class.save!
+ end
+
+ def execute_post_create_hook!
+ script = File.expand_path("~/.gitauth/post-create")
+ if File.exist?(script) && File.executable?(script)
+ system(script, @name, @path)
+ return $?.success?
+ else
+ # If there isn't a file, run it ourselves.
+ return true
+ end
end
end
end
\ No newline at end of file