| |   |
| 34 | 34 | protected |
| 35 | 35 | def post_create(path) |
| 36 | 36 | FileUtils.touch(File.join(path, "git-daemon-export-ok")) |
| 37 | | system(%Q{GIT_DIR="#{path}" git-update-server-info}) |
| 37 | execute_command(%Q{chmod +x #{File.join(path, "hooks/post-update")}}) |
| 38 | execute_command(%Q{GIT_DIR="#{path}" git-update-server-info}) |
| 39 | end |
| 40 | |
| 41 | def execute_command(command) |
| 42 | system(command) |
| 38 | 43 | end |
| 39 | 44 | end |
| 40 | 45 | end |
| toggle raw diff |
--- a/lib/git_backend.rb
+++ b/lib/git_backend.rb
@@ -34,7 +34,12 @@ class GitBackend
protected
def post_create(path)
FileUtils.touch(File.join(path, "git-daemon-export-ok"))
- system(%Q{GIT_DIR="#{path}" git-update-server-info})
+ execute_command(%Q{chmod +x #{File.join(path, "hooks/post-update")}})
+ execute_command(%Q{GIT_DIR="#{path}" git-update-server-info})
+ end
+
+ def execute_command(command)
+ system(command)
end
end
end
\ No newline at end of file |
| |   |
| 15 | 15 | Dir.should_receive(:chdir).with(path).and_yield(path) |
| 16 | 16 | Git.should_receive(:init).with(path, :repository => path).and_return(true) |
| 17 | 17 | FileUtils.should_receive(:touch).with(File.join(path, "git-daemon-export-ok")) |
| 18 | GitBackend.should_receive(:execute_command).with( |
| 19 | %Q{chmod +x #{File.join(path, "hooks/post-update")}} |
| 20 | ).and_return(true) |
| 21 | GitBackend.should_receive(:execute_command).with( |
| 22 | %Q{GIT_DIR="#{path}" git-update-server-info} |
| 23 | ).and_return(true) |
| 18 | 24 | |
| 19 | 25 | GitBackend.create(path) |
| 20 | 26 | end |
| … | … | |
| 30 | 30 | target_path = repositories(:johans).full_repository_path |
| 31 | 31 | Git.should_receive(:clone).with(source_path, target_path, :bare => true).and_return(true) |
| 32 | 32 | FileUtils.should_receive(:touch).with(File.join(target_path, "git-daemon-export-ok")) |
| 33 | GitBackend.should_receive(:execute_command).with( |
| 34 | %Q{chmod +x #{File.join(target_path, "hooks/post-update")}} |
| 35 | ).and_return(true) |
| 36 | GitBackend.should_receive(:execute_command).with( |
| 37 | %Q{GIT_DIR="#{target_path}" git-update-server-info} |
| 38 | ).and_return(true) |
| 33 | 39 | |
| 34 | 40 | GitBackend.clone(target_path, source_path) |
| 35 | 41 | end |
| toggle raw diff |
--- a/spec/models/git_backend_spec.rb
+++ b/spec/models/git_backend_spec.rb
@@ -15,6 +15,12 @@ describe GitBackend do
Dir.should_receive(:chdir).with(path).and_yield(path)
Git.should_receive(:init).with(path, :repository => path).and_return(true)
FileUtils.should_receive(:touch).with(File.join(path, "git-daemon-export-ok"))
+ GitBackend.should_receive(:execute_command).with(
+ %Q{chmod +x #{File.join(path, "hooks/post-update")}}
+ ).and_return(true)
+ GitBackend.should_receive(:execute_command).with(
+ %Q{GIT_DIR="#{path}" git-update-server-info}
+ ).and_return(true)
GitBackend.create(path)
end
@@ -24,6 +30,12 @@ describe GitBackend do
target_path = repositories(:johans).full_repository_path
Git.should_receive(:clone).with(source_path, target_path, :bare => true).and_return(true)
FileUtils.should_receive(:touch).with(File.join(target_path, "git-daemon-export-ok"))
+ GitBackend.should_receive(:execute_command).with(
+ %Q{chmod +x #{File.join(target_path, "hooks/post-update")}}
+ ).and_return(true)
+ GitBackend.should_receive(:execute_command).with(
+ %Q{GIT_DIR="#{target_path}" git-update-server-info}
+ ).and_return(true)
GitBackend.clone(target_path, source_path)
end |