我已经编写了一个非常简单的“deploy”脚本,作为我裸的git仓库中的
变量如下:
我已经尝试了从这个bash脚本中的文件'更新',它使用
但是,当执行上述脚本时,我会遇到以下错误:
有没有办法在我的Ruby脚本中像bash脚本中的
谢谢,
Jannis
post-update
钩子运行。变量如下:
live domain = ~/mydomain.com
staging domain = ~/stage.mydomain.com
git repo location = ~/git.mydomain.com/thisrepo.git (bare)
core = ~/git.mydomain.com/thisrepo.git
core == added remote into each live & stage gits
both live
& stage
已经初始化了git仓库(非裸仓库),我已将我的裸仓库添加为它们各自的远程仓库(命名为core
),这样git pull core stage
或git pull core live
就会从core
仓库的相应分支
中拉取更新的文件。
脚本如下:
#!/usr/bin/env ruby
# Loop over each passed in argument
ARGV.each do |branch|
# If it matches the stage then 'update' the staging files
if branch == "refs/heads/stage"
puts ""
puts "Looks like the staging branch was updated."
puts "Running a tree checkout now…"
puts ""
`cd ~/stage.mydomain.com`
`unset GIT_DIR` # <= breaks!
`git pull core stage`
puts ""
puts "Tree pull completed on staging branch."
puts ""
# If it's a live site update, update those files
elsif branch == "refs/heads/live"
puts ""
puts "Looks like the live branch was updated."
puts "Running a tree checkout now…"
puts ""
`cd ~/mydomain.com`
`unset GIT_DIR` # <= breaks!
`git pull core live`
puts ""
puts "Tree checkout completed on live branch."
puts ""
end
end
我已经尝试了从这个bash脚本中的文件'更新',它使用
unset GIT_DIR
来运行下一个git命令,例如git pull core stage
。在这里,core
是我在服务器上不同文件夹中的repo的添加remote
。但是,当执行上述脚本时,我会遇到以下错误:
remote: hooks/post-update:35: command not found: unset GIT_DIR
remote: fatal: /usr/lib/git-core/git-pull cannot be used without a working tree.
有没有办法在我的Ruby脚本中像bash脚本中的
unset GIT_DIR
一样做同样的事情?谢谢,
Jannis
[update:live]
或[update:stage]
的东西来触发此pull
操作... - Jannis