Skip to content

Commit c0568fb

Browse files
yubakoppen
authored andcommitted
uses Dir.chdir instead of --git-dir
It is hard to handle special characters appropriately to maintain --git-dir option dynamically. So repository directory should be given as current directory, instead of command line option. Dir.chdir-with-block takes effect only in the trailing block.
1 parent 1d18d33 commit c0568fb

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

app/controllers/github_hook_controller.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,18 @@ def exec(command)
5252
logfile.unlink
5353
end
5454

55-
def git_command(command, repository)
56-
GIT_BIN + " --git-dir=\"#{repository.url}\" #{command}"
55+
def git_command(command)
56+
GIT_BIN + " #{command}"
5757
end
5858

5959
# Fetches updates from the remote repository
6060
def update_repository(repository)
61-
command = git_command('fetch origin', repository)
62-
if exec(command)
63-
command = git_command("fetch origin \"+refs/heads/*:refs/heads/*\"", repository)
64-
exec(command)
61+
Dir.chdir(repository.url) do
62+
command = git_command('fetch origin')
63+
if exec(command)
64+
command = git_command("fetch origin \"+refs/heads/*:refs/heads/*\"")
65+
exec(command)
66+
end
6567
end
6668
end
6769

0 commit comments

Comments
 (0)